Repository navigation
ci(site): derive the site version from tags and rebuild on release - #192
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The landing page hero badge was a hand-set value in
docs/hugo.tomlthat 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 asHUGO_PARAMS_VERSION:The value in
hugo.tomlstays, 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, notfetch-tags.actions/checkoutpasses--no-tagsat depth 1, andfetch-tags: truebrings the tag refs without the historygit describehas to walk to reach them. I checked both against a real shallow clone — with tags fetched but the history shallow, describe still fails: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.ymldispatchespages.ymlonce the release is published.That runs as its own job rather than a final step on
goreleaser.actions: writeis 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_REPOto name the repo thatghwould 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:443was already on the release job's allow-list, so that is unchanged.Verification
actionlintis clean across all workflows. Every action pin is untouched. The derivation was run locally against the real tags —v0.7.0resolves to0.7.0, and the badge in a build with that value readsv0.7.0 · macOS · single binary;HUGO_PARAMS_VERSIONdemonstrably overrides the config value. The no-tag path falls back and still exits 0. Every past release tag is an ancestor ofmain, so dispatching on--ref mainwill resolve the newest one.This PR touches
pages.yml, so the PR build itself exercises the new step — its log is the real proof thatfetch-depth: 0resolves the tag on a runner.Note, not addressed here
--match 'v*'also matches pre-release tags, andrelease.ymltriggers onv*too. Cutting av0.8.0-rc.1would therefore put0.8.0-rc.1on 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.