Skip to content

fix(site): show release tag instead of "vunknown" version badge#227

Merged
ktn-jamf merged 1 commit into
mainfrom
worktree-fix-site-version-parse
May 31, 2026
Merged

fix(site): show release tag instead of "vunknown" version badge#227
ktn-jamf merged 1 commit into
mainfrom
worktree-fix-site-version-parse

Conversation

@ktn-jamf
Copy link
Copy Markdown
Collaborator

Problem

The showcase site rendered vunknown as the version badge.

Root cause is a broken implicit contract. The site generator ran jamf-cli version and parsed the first line expecting the text banner jamf-cli <version> (fields[1]). But the global -o default is json, and since #195 the version command honors -o — so the bare call now returns JSON whose first line is just {. parseVersion saw a single field, fell into its len(fields) < 2"unknown" branch, and catalog.js prefixed vvunknown. This affected the deployed site, since the deploy workflow makes the same flagless call.

Fix

generator/site/main.go:

  • Invoke version -o json explicitly and read the structured version field, with a fallback to the legacy banner for binaries that predate -o support (the deploy builds the binary from the latest release tag while taking the generator from main, so the generator can't assume the binary speaks JSON).
  • Strip the git-describe -dirty marker. The deploy overlays site files from main onto the tagged checkout, which dirties the tree — without this, a clean tag surfaced as v1.17.0-dirty.

Result

All build paths now resolve to the clean nearest release tag:

Build path git describe Badge
Deploy on push to main (tag + dirty overlay) v1.17.0-dirty v1.17.0
Release event v1.17.0 v1.17.0
Local make site v1.17.0-25-g74846ff-dirty v1.17.0

Testing

  • Added JSON TestParseVersion cases incl. both dirty-build scenarios; existing banner cases retained (now exercise the fallback path). Full generator/site package passes; go vet, gofmt, go build ./... clean.
  • Verified end-to-end by simulating the deploy: checked out v1.17.0, applied the workflow's overlay, built the binary, ran the fixed generator → commands.json reports "version": "1.17.0".

🤖 Generated with Claude Code

The site generator invoked `jamf-cli version` and parsed the first line
expecting the text banner `jamf-cli <version>`. But the global `-o`
default is `json`, and since #195 the version command honors it — so the
bare call returns JSON, whose first line is `{`. parseVersion saw a single
field, returned "unknown", and the display layer prefixed `v`, rendering
"vunknown" on the deployed site.

Fix:
- Invoke `version -o json` explicitly and read the structured `version`
  field, falling back to the legacy banner for older binaries that
  predate `-o` support (the deploy builds the binary from the latest
  release tag while taking the generator from main).
- Strip the git-describe `-dirty` marker so the clean release tag shows.
  The deploy overlays site files from main onto the tagged checkout,
  dirtying the tree; without this a clean tag surfaced as "v1.17.0-dirty".

All build paths (deploy, release, local `make site`) now resolve to the
nearest release tag, e.g. v1.17.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ktn-jamf ktn-jamf enabled auto-merge (squash) May 31, 2026 04:43
@ktn-jamf ktn-jamf merged commit 4a493b1 into main May 31, 2026
2 checks passed
@ktn-jamf ktn-jamf deleted the worktree-fix-site-version-parse branch May 31, 2026 04:48
ktn-jamf added a commit that referenced this pull request May 31, 2026
Resolve conflict in generator/site/main.go. main's #227 landed an equivalent
"parse version from JSON" fix (extractRawVersion) that also trims the bare
"-dirty" marker — strictly more complete than this branch's rawVersion, which
missed the clean-tag-built-on-dirty-tree case. Kept main's extractRawVersion +
parseVersion; dropped the branch's redundant rawVersion.

The branch's real contribution (llms.txt "For AI Agents" contract + Output
Formats expansion in renderLLMSTxt) auto-merged cleanly. Both branches'
parseVersion JSON test cases were retained as complementary coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants