From 8db311cb9983ac16012f74e9948e282a9f98b384 Mon Sep 17 00:00:00 2001 From: Baipyrus <39416358+Baipyrus@users.noreply.github.com> Date: Sun, 1 Sep 2024 14:43:10 +0200 Subject: [PATCH] uploading build artifact on tag in releases --- .github/workflows/build.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 731e1f9..865aae8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,7 @@ name: Go on: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + tags: 'v*' env: GOOS: windows @@ -18,9 +16,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV + - name: Get GoLang version + run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV + - name: Set up Go uses: actions/setup-go@v4 with: @@ -33,7 +34,21 @@ jobs: - name: Build project run: go build -o build/ -v ./... - - name: Upload executable - uses: actions/upload-artifact@v4 + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - path: build/ProxySwitcher.exe + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + + - name: Upload executable + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: build/ProxySwitcher.exe + asset_name: ProxySwitcher.exe + asset_content_type: application/octet-stream