uploading build artifact on tag in releases

This commit is contained in:
Baipyrus 2024-09-01 14:43:10 +02:00 committed by GitHub
parent da23ed7440
commit 8db311cb99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,9 +5,7 @@ name: Go
on: on:
push: push:
branches: [ "main" ] tags: 'v*'
pull_request:
branches: [ "main" ]
env: env:
GOOS: windows GOOS: windows
@ -18,9 +16,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 - name: Set up Go
uses: actions/setup-go@v4 uses: actions/setup-go@v4
with: with:
@ -33,7 +34,21 @@ jobs:
- name: Build project - name: Build project
run: go build -o build/ -v ./... run: go build -o build/ -v ./...
- name: Upload executable - name: Create release
uses: actions/upload-artifact@v4 id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: 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