Compare commits

..
1 Commits
Author SHA1 Message Date
dependabot[bot] 76beaed9e5 build(deps): bump actions/setup-go from 6 to 7
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 6 to 7.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-22 14:14:21 +00:00
6 changed files with 202 additions and 67 deletions

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
name: build
on:
push:
branches: ['**']
tags: ['v*']
jobs:
go:
uses: self:KofTwentyTwo/ci-workflows/.gitea/workflows/go.yaml@v1
with:
go-version: '1.26'
golangci-lint: true
race: true
test-args: -coverpkg=./internal/...,./cmd/... -covermode=atomic -coverprofile=cover.out
# 100% coverage gate (.testcoverage.yml), then the plain build.
commands: |
go run github.com/vladopajic/go-test-coverage/v2@v2.18.8 --config=.testcoverage.yml
go build ./...
release-commands: scripts/build-release.sh "${GITHUB_REF_NAME#v}"
artifacts: dist/*
+121
View File
@@ -0,0 +1,121 @@
name: CI
on:
pull_request:
branches:
- develop
- main
- release/**
- rc/**
push:
branches:
- develop
- main
- release/**
- rc/**
permissions:
contents: read
jobs:
go-checks:
name: Go checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26"
cache: true
- name: Check formatting
run: |
unformatted="$(gofmt -l .)"
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-clean:"
echo "$unformatted"
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
# v8 installs golangci-lint v2.x, which understands the v2 .golangci.yml
# schema (version/formatters). latest pulls a build made with a current Go
# toolchain, satisfying the module's go directive.
version: latest
- name: Run tests with coverage profile
run: |
go test ./... -race \
-coverpkg=./internal/...,./cmd/... \
-covermode=atomic \
-coverprofile=cover.out
- name: Upload coverage profile
uses: actions/upload-artifact@v7
with:
name: coverage-profile-${{ github.run_id }}-${{ github.sha }}
path: cover.out
if-no-files-found: error
- name: Enforce 100% coverage gate
# go-test-coverage is a CI-only tool, run via `go run` so it never becomes a
# go.mod dependency. The gate FAILS the build when total coverage on
# ./internal/...,./cmd/... drops below the 100 threshold in .testcoverage.yml,
# which documents the only two exclusions (the main() shim and gen_spdx.go).
run: go run github.com/vladopajic/go-test-coverage/v2@v2.18.8 --config=.testcoverage.yml
- name: Build
run: go build ./...
macos-build:
name: macOS branch build
runs-on: macos-15
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26"
cache: true
- name: Build binary
run: go build -o license-tool ./cmd/license-tool
- name: Upload branch binary
uses: actions/upload-artifact@v7
with:
name: license-tool-${{ github.run_id }}-${{ github.sha }}-macos
path: license-tool
if-no-files-found: error
windows-build:
name: Windows branch build
runs-on: windows-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26"
cache: true
- name: Build binary
run: go build -o license-tool.exe ./cmd/license-tool
- name: Upload branch binary
uses: actions/upload-artifact@v7
with:
name: license-tool-${{ github.run_id }}-${{ github.sha }}-windows
path: license-tool.exe
if-no-files-found: error
+39
View File
@@ -0,0 +1,39 @@
name: Release
# Run whenever a semver release tag is pushed (e.g. v1.0.0, v1.2.3-rc.1).
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
permissions:
contents: write
jobs:
goreleaser:
name: GoReleaser
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
# GoReleaser needs full history and all tags to compute the changelog
# and resolve the previous tag.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26.4"
cache: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
with:
version: v2.16.0
args: release --clean
env:
# GITHUB_TOKEN publishes the GitHub Release in this repo.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# HOMEBREW_TAP_TOKEN pushes the generated cask to KofTwentyTwo/homebrew-tap.
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
+2 -2
View File
@@ -5,8 +5,8 @@ on [RELEASING.md](./RELEASING.md) (which is the short reference) with the comple
process: integrating feature work, choosing a version, running the gate, tagging, and
verifying the published artifacts.
Releases are built by `scripts/build-release.sh` and published to the Gitea release by
the tag build of `.gitea/workflows/build.yaml` (see RELEASING.md). There is **no version constant in source** — the
Releases are built by [GoReleaser](https://goreleaser.com) and published by the
`Release` GitHub Actions workflow. There is **no version constant in source** — the
version is injected at build time via `-ldflags` (`main.version`, `main.commit`,
`main.date`) when the workflow runs against a pushed tag.
+40 -12
View File
@@ -4,10 +4,7 @@
> conflict resolution, tagging, and post-release verification) see [RELEASES.md](./RELEASES.md).
> This file is the short reference.
CI and releases run on Gitea Actions (`.gitea/workflows/build.yaml`, the shared
`KofTwentyTwo/ci-workflows` Go workflow). A `v*` tag runs every gate, then
`scripts/build-release.sh` builds the archives and CI attaches them with a `SHA256SUMS`
to the tag's Gitea release. `.goreleaser.yaml` remains for local snapshot checks.
Releases are built with [GoReleaser](https://goreleaser.com) and published by GitHub Actions.
## Changelog Management
@@ -75,8 +72,8 @@ git tag vX.Y.Z-rc.N
git push origin vX.Y.Z-rc.N
```
The tag build creates a Gitea prerelease (any tag with a `-` suffix) with the archives and
`SHA256SUMS`.
The `Release` workflow builds all configured target binaries and creates a GitHub prerelease
(the `release.prerelease: auto` setting marks any tag with a prerelease suffix as a prerelease).
## Production Release
@@ -89,7 +86,7 @@ From `main`:
git commit -am "docs: changelog for v$VERSION"
```
3. Push `main` and wait for CI to pass on the release commit.
3. Push `main` and wait for CI and CodeQL to pass on the release commit.
4. Tag and push. Prefer a signed annotated tag:
```bash
@@ -97,10 +94,41 @@ From `main`:
git push origin vX.Y.Z
```
The tag build runs every CI gate, then `scripts/build-release.sh <version>` cross-compiles the
mac/linux arm64+amd64 and windows amd64 binaries into `dist/` archives, and CI attaches them
and a `SHA256SUMS` to the tag's Gitea release.
The `Release` workflow runs `goreleaser release --clean`, which cross-compiles the
mac/linux arm64+amd64 and windows amd64 binaries, builds the archives and `checksums.txt`,
creates the GitHub Release, and publishes the Homebrew cask to:
The Homebrew cask in `KofTwentyTwo/homebrew-tap` is not updated by CI; update it by hand from
the release's `SHA256SUMS` until the tap has its own workflow.
```text
KofTwentyTwo/homebrew-tap
```
End users install with:
```bash
brew install --cask KofTwentyTwo/tap/license-tool
```
## Required GitHub Setup
Create or verify a public Homebrew tap repository:
```text
KofTwentyTwo/homebrew-tap
```
Add a repository Actions secret on `KofTwentyTwo/license-tool` named:
```text
HOMEBREW_TAP_TOKEN
```
The token needs contents write access to `KofTwentyTwo/homebrew-tap`, because the release
workflow checks out that repository and commits cask updates. Do not hardcode this token
in workflow files.
Before the first production release:
- Protect or manage the `main` and `develop` branches according to the branch flow above.
- Confirm `HOMEBREW_TAP_TOKEN` can write to `KofTwentyTwo/homebrew-tap`.
- Confirm the local push path works with `git ls-remote --heads origin`.
- Re-run `goreleaser check` and `goreleaser release --snapshot --clean`.
-34
View File
@@ -1,34 +0,0 @@
#!/usr/bin/env bash
# Cross-compile the release archives into dist/ (the Gitea CI runs this on v* tags).
#
# Same targets, names and ldflags as .goreleaser.yaml: darwin/linux amd64+arm64 and
# windows amd64; tar.gz everywhere except Windows, which gets a zip.
#
# Usage: scripts/build-release.sh <version> (for example 1.2.3 or 1.2.3-rc.1)
set -euo pipefail
version=${1:?usage: scripts/build-release.sh <version>}
commit=$(git rev-parse HEAD)
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
ldflags="-s -w -X main.version=$version -X main.commit=$commit -X main.date=$date"
cd "$(dirname "${BASH_SOURCE[0]}")/.."
rm -rf dist && mkdir dist
for target in darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64; do
os=${target%/*}
arch=${target#*/}
name=license-tool_${version}_${os}_${arch}
ext=
[[ $os == windows ]] && ext=.exe
mkdir "dist/$name"
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath -ldflags "$ldflags" \
-o "dist/$name/license-tool$ext" ./cmd/license-tool
cp README.md LICENSE CHANGELOG.md "dist/$name/"
if [[ $os == windows ]]; then
(cd "dist/$name" && python3 -m zipfile -c "../$name.zip" ./*)
else
tar -czf "dist/$name.tar.gz" -C "dist/$name" .
fi
rm -r "dist/${name:?}"
done
ls -l dist