Artifact d747a91302d128ce66f9bc8ec17624a70b0205f5a65641c5b9d3e71b17cfe62f:
- Executable file
scripts/sync-version.sh
— part of check-in
[ab1e500bc4]
at
2026-04-26 15:20:11
on branch trunk
— feat(landing): inject version from latest git tag at build time (#13)
Replace the three hardcoded "0.4.2" strings in the landing layout with {{ .Site.Params.version }} template directives. Add scripts/sync-version.sh that reads the latest git tag via 'git describe --tags --abbrev=0' and rewrites hugo.yaml's params.version line. Wire it into wrangler.jsonc's build command so Cloudflare's git-integrated build picks up new tags automatically — push a commit to main with a fresh tag, CF rebuilds, the landing shows the new version with no PR required to bump strings.
Footer year switched to {{ now.Year }} so 2027 doesn't surprise anyone.
Local fallback: when no tags are reachable (very early dev), the script exits cleanly and the layout's 'default' filter falls back to the value already in hugo.yaml. (user: [email protected], size: 1308) [annotate] [blame] [check-ins using]
#!/usr/bin/env bash # Read the latest git tag and write it into docs/site/hugo.yaml's # params.version so the landing page picks it up at build time. Run by # the Cloudflare build before Hugo invokes; safe to run locally too — # it only edits the working tree, never commits. # # Falls back to whatever value is already in hugo.yaml if no tags are # reachable (e.g., very early dev with no releases yet). set -euo pipefail HUGO_YAML="docs/site/hugo.yaml" # Cloudflare Workers Builds may not fetch tag refs by default; pull them # so 'git describe' can find the latest. Tag refs are tiny — no depth # limit (--depth=1 would break full clones by marking commits shallow). git fetch --tags --no-shallow >/dev/null 2>&1 \ || git fetch --tags >/dev/null 2>&1 \ || true if TAG=$(git describe --tags --abbrev=0 2>/dev/null); then VERSION="${TAG#v}" else echo "sync-version: no git tags reachable, leaving hugo.yaml untouched" >&2 exit 0 fi # Replace the version line. Use a temp file to stay portable across # GNU sed (Linux/CF) and BSD sed (macOS). awk -v v="${VERSION}" ' /^ version: "/ { print " version: \"" v "\""; next } { print } ' "${HUGO_YAML}" > "${HUGO_YAML}.tmp" mv "${HUGO_YAML}.tmp" "${HUGO_YAML}" echo "sync-version: hugo.yaml params.version set to ${VERSION}"