-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(github): add Windows build and release workflow
- Create new GitHub Actions workflow for Windows builds - Set up Go environment and build project - Check if release exists and create if necessary - Upload Windows executable to release
- Loading branch information
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: build-win | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
tags: [ 'v*' ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
|
||
build: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true # This tells checkout action to clone submodules | ||
token: ${{ secrets.GH_PAT }} # Personal Access Token with repo scope | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.3' | ||
|
||
- name: pull | ||
run: git submodule update --init --recursive | ||
|
||
- name: Build | ||
run: go build -o lspvi-win-x64 | ||
|
||
|
||
|
||
- name: Check if release exists | ||
id: check_release | ||
shell: bash | ||
run: | | ||
if gh release view ${{ github.ref_name }} &> /dev/null; then | ||
echo "release_exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "release_exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RTOKEN}} | ||
|
||
|
||
- name: Create Release | ||
id: create_release | ||
if: steps.check_release.outputs.release_exists == 'false' && startsWith(github.ref, 'refs/tags/') | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RTOKEN }} | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
release_name: Release ${{ github.ref_name }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Get Release Upload URL | ||
id: get_upload_url | ||
shell: bash | ||
run: | | ||
upload_url=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} | jq -r .upload_url) | ||
echo $upload_url | ||
if [[ $upload_url == "" ]]; then | ||
echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT | ||
fi | ||
# echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT | ||
# echo "upload_url=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} | jq -r .upload_url)" >> $GITHUB_OUTPUT | ||
# if [ "${{ steps.check_release.outputs.release_exists }}" == "true" ]; then | ||
# echo "upload_url=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} | jq -r .upload_url)" >> $GITHUB_OUTPUT | ||
# else | ||
# echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT | ||
# fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RTOKEN }} | ||
|
||
|
||
|
||
|
||
|
||
|
||
- name: Upload Artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RTOKEN }} | ||
with: | ||
upload_url: ${{ steps.get_upload_url.outputs.upload_url }} | ||
asset_path: ./lspvi-win-x64 | ||
asset_name: lspvi-win-x64 | ||
asset_content_type: application/octet-stream | ||
|