Skip to content

feat(setup-go): release-cache — a release-scoped Go cache for goreleaser jobs - #56

Closed
blairham wants to merge 1 commit into
mainfrom
feat/setup-go-release-cache
Closed

feat(setup-go): release-cache — a release-scoped Go cache for goreleaser jobs#56
blairham wants to merge 1 commit into
mainfrom
feat/setup-go-release-cache

Conversation

@blairham

Copy link
Copy Markdown
Contributor

Why

Release jobs rebuild the whole cross-compile matrix nearly cold every time. actions/setup-go's built-in cache can't help them: (1) its key is exact-match on go.sum — no restore-keys — so any dependency bump is a fully cold build; (2) a cache key's snapshot is immutable and saved by whichever job first claims it, usually a CI test job whose GOCACHE contains only host-platform test builds — useless for the other five GOOS/GOARCH targets. k4a's last release spent 457s of its 9 minutes inside 'Run GoReleaser' for exactly this reason.

What

Opt-in release-cache: true on the setup-go composite:

  • Disables the built-in cache and adds an explicit actions/cache over ~/go/pkg/mod + ~/.cache/go-build.
  • Key go-release-<os>-<hash(go.mod, go.sum)> — namespaced away from CI's cache, toolchain bumps roll it.
  • restore-keys prefix fallback — a dependency bump restores the previous release's cache and compiles incrementally instead of cold.
  • The post step saves at job end, after goreleaser — so the snapshot carries the build cache for every cross-compiled target, and the next release restores a full-matrix warm cache.

Default false: no behavior change for any existing caller.

Rollout

Merge this first, then flip release-cache: true in the release.yml of the goreleaser repos (k4a, k5s, cloudctl, cwlogs, pp-tui) — k4a PR follows as the first caller. First release per repo populates the cache; the second one gets the speedup (expect k4a well under half its current 9min).

…ser jobs

setup-go's built-in cache is wrong for goreleaser jobs twice over: its
key is exact-match on go.sum, so any dependency bump means a fully cold
6-target build; and the snapshot for a key is saved by whichever job
first claims it — usually a CI test job, whose GOCACHE holds only
host-platform test builds and warms none of the cross-compile targets.
k4a's last release spent 7.6 of its 9 minutes inside goreleaser for
exactly this reason.

release-cache: true replaces it with a go-release-* namespaced
module+build cache: restore-keys keeps dependency bumps warm, and the
post step saves it after goreleaser has built every GOOS/GOARCH target,
so the next release restores a build cache covering the full matrix.
Default false — no change for any existing caller.
@blairham

Copy link
Copy Markdown
Contributor Author

Superseded by #58, which generalizes this: per-job cache scopes mean a goreleaser job (job id release) automatically gets its own flag-set-specific cache with restore-keys, saved at job end after goreleaser — everything release-cache: true provided, for every job shape, with zero caller opt-in. Same-file conflict resolved by withdrawing this one.

@blairham blairham closed this Aug 15, 2026
@blairham
blairham deleted the feat/setup-go-release-cache branch August 15, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant