* Implement test and release jobs for versioned tags * Build binaries for multiple OS/architecture targets * Create release and upload assets to GitHub * Add release-version target in Makefile for version bumping
58 lines
1.3 KiB
YAML
58 lines
1.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Test
|
|
run: go test ./...
|
|
|
|
- name: Lint
|
|
run: go vet ./...
|
|
|
|
release:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build release binaries
|
|
run: |
|
|
VERSION="${GITHUB_REF_NAME}"
|
|
for target in "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "windows/amd64"; do
|
|
GOOS="${target%/*}"
|
|
GOARCH="${target#*/}"
|
|
EXT=""
|
|
[ "$GOOS" = "windows" ] && EXT=".exe"
|
|
NAME="unitdore-${GOOS}-${GOARCH}${EXT}"
|
|
GOOS="$GOOS" GOARCH="$GOARCH" go build \
|
|
-ldflags "-X main.version=${VERSION}" \
|
|
-o "$NAME" .
|
|
echo "Built $NAME"
|
|
done
|
|
|
|
- name: Create release and upload assets
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: unitdore-*
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|