diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml new file mode 100644 index 00000000..34e9a3a1 --- /dev/null +++ b/.github/workflows/win.yml @@ -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 +