Skip to content

Commit

Permalink
ci(github): add Windows build and release workflow
Browse files Browse the repository at this point in the history
- 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
wellcomez committed Nov 1, 2024
1 parent bff9c5a commit 26e3f3e
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/win.yml
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

0 comments on commit 26e3f3e

Please sign in to comment.