Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosuxx committed Jul 15, 2023
1 parent 185d907 commit 4070f66
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release WireGuard Show Binary

on: push

env:
BINARY_NAME: wg-show
MAIN_GO_FILE: cmd/wgshow/main.go
GO_VERSION: 1.20.5

jobs:
build:
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Run build
run: |
GOOS=linux GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}-linux-x86_64 ${{ env.MAIN_GO_FILE }}
GOOS=linux GOARCH=arm64 go build -o build/${{ env.BINARY_NAME }}-linux-aarch64 ${{ env.MAIN_GO_FILE }}
GOOS=darwin GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}-darwin-x86_64 ${{ env.MAIN_GO_FILE }}
GOOS=darwin GOARCH=arm64 go build -o build/${{ env.BINARY_NAME }}-darwin-aarch64 ${{ env.MAIN_GO_FILE }}
GOOS=windows GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}-windows-x86_64.exe ${{ env.MAIN_GO_FILE }}
GOOS=windows GOARCH=arm64 go build -o build/${{ env.BINARY_NAME }}-windows-aarch64.exe ${{ env.MAIN_GO_FILE }}
- name: Create artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.BINARY_NAME }}-binaries
path: build/

release:
if: startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download binaries artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.BINARY_NAME }}-binaries
path: build/
- name: Uploaded binaries as release assets
run: |
set -x
tag_name="${GITHUB_REF##*/}"
assets=()
for binary in ./build/*; do
assets+=("-a" "${binary}")
done
hub release edit "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 4070f66

Please sign in to comment.