Skip to content

ci(site): derive the site version from tags and rebuild on release - #192

Merged
ryanlewis merged 1 commit into
mainfrom
ci/site-version
Sep 5, 2026
Merged

ryanlewis merged 1 commit into
mainfrom
ci/site-version

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

The landing page hero badge was a hand-set value in docs/hugo.toml that nothing checked, so it went stale the moment a release went out. This makes it track the tags, and makes a release rebuild the site.

Deriving the version

The Pages build resolves the newest v* tag reachable from the ref being built and hands it to Hugo as HUGO_PARAMS_VERSION:

if tag=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null); then
  echo "HUGO_PARAMS_VERSION=${tag#v}" >> "$GITHUB_ENV"
fi

The value in hugo.toml stays, now documented as the local-dev fallback: a build with no tag in reach keeps using it rather than failing.

This needs fetch-depth: 0, not fetch-tags. actions/checkout passes --no-tags at depth 1, and fetch-tags: true brings the tag refs without the history git describe has to walk to reach them. I checked both against a real shallow clone — with tags fetched but the history shallow, describe still fails:

fatal: No tags can describe '3000b466...'.

Either shallow option would have left the badge silently falling back on every build, with nothing failing to say so.

Rebuilding on release

goreleaser creates the release with the workflow's own token, and a release made that way does not trigger other workflows. So release.yml dispatches pages.yml once the release is published.

That runs as its own job rather than a final step on goreleaser. actions: write is granted per job, not per step, so putting it on the release job would hand it to goreleaser and everything goreleaser downloads — the one job holding the signing keys and the tap token, and the one wrapped in a harden-runner block policy for exactly that reason. Splitting it also stops a failed dispatch from failing a release that has already shipped, where re-running the job would re-run goreleaser against a release that now exists.

The new job carries no secrets and no checkout, so it gets GH_REPO to name the repo that gh would otherwise infer from a git remote. No harden-runner on it: per the repo's own convention, egress hardening is earned by holding something worth stealing, and this job holds nothing. api.github.com:443 was already on the release job's allow-list, so that is unchanged.

Verification

actionlint is clean across all workflows. Every action pin is untouched. The derivation was run locally against the real tags — v0.7.0 resolves to 0.7.0, and the badge in a build with that value reads v0.7.0 · macOS · single binary; HUGO_PARAMS_VERSION demonstrably overrides the config value. The no-tag path falls back and still exits 0. Every past release tag is an ancestor of main, so dispatching on --ref main will resolve the newest one.

This PR touches pages.yml, so the PR build itself exercises the new step — its log is the real proof that fetch-depth: 0 resolves the tag on a runner.

Note, not addressed here

--match 'v*' also matches pre-release tags, and release.yml triggers on v* too. Cutting a v0.8.0-rc.1 would therefore put 0.8.0-rc.1 on the public landing page. No rc tags exist today and whether an rc should move the badge is a product decision, so the matcher is left alone.

The landing page hero badge was a hand-set value in docs/hugo.toml that
nothing checked, so it went stale the moment a release went out.

The Pages build now derives it from the newest v* tag reachable from the
ref being built and passes it to Hugo as HUGO_PARAMS_VERSION. The value
in hugo.toml stays as the local-dev fallback, and a build with no tag in
reach keeps using it rather than failing.

This needs the full history, not just the tags. actions/checkout passes
--no-tags at depth 1, and fetch-tags brings the tag refs without the
history git describe has to walk to reach them, so either way the badge
would quietly fall back on every build.

Releases are created by goreleaser using this workflow's own token, and a
release made that way does not trigger other workflows, so release.yml
now dispatches pages.yml once the release is published. That runs as its
own job: actions: write is granted per job, not per step, so putting it
on the goreleaser job would hand it to goreleaser and everything
goreleaser downloads — the one job holding the signing keys and the tap
token. Keeping it separate also stops a failed dispatch from failing a
release that has already shipped, where re-running the job would re-run
goreleaser against a release that now exists.
@ryanlewis
ryanlewis merged commit 70afd80 into main Sep 5, 2026
10 checks passed
@ryanlewis
ryanlewis deleted the ci/site-version branch September 5, 2026 17:44
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