vet, gofmt and go test on every push and pull request. A v* tag also builds the amd64 and arm64 binaries with SHA256SUMS and publishes a GitHub release with the tag message as notes. The release job runs on GitHub only, as Forgejo reads .github/workflows too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: gofmt
|
|
run: test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; }
|
|
- run: go vet ./...
|
|
- run: go test ./...
|
|
|
|
release:
|
|
# A v* tag builds the release binaries and publishes them, on GitHub
|
|
# only: Forgejo reads this directory too and has its own releases.
|
|
if: startsWith(github.ref, 'refs/tags/v') && github.server_url == 'https://github.com'
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Build
|
|
env:
|
|
V: ${{ github.ref_name }}
|
|
run: |
|
|
mkdir dist
|
|
for a in amd64 arm64; do
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=$a go build -trimpath -ldflags "-s -w -X main.version=$V" -o dist/interzone-linux-$a .
|
|
done
|
|
(cd dist && sha256sum interzone-linux-* > SHA256SUMS)
|
|
./dist/interzone-linux-amd64 -version
|
|
- name: Publish
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
V: ${{ github.ref_name }}
|
|
run: |
|
|
# The tag's annotation (or commit message) becomes the notes.
|
|
git fetch --force origin "refs/tags/$V:refs/tags/$V"
|
|
notes=$(git tag -l --format='%(contents)' "$V")
|
|
gh release create "$V" dist/* --title "interzone $V" --notes "${notes:-interzone $V}" --verify-tag
|