Skip to content

Commit 5e13dcc

Browse files
committed
ci(release): verify git tag matches Version constant (gh#3459)
Add `make check-version-tag` target that fails when HEAD is tagged vX.Y.Z and internal/cmd/version.go's Version constant does not equal X.Y.Z. Wire it into release.yml before GoReleaser so a mismatched tag aborts the release instead of shipping a binary that reports the wrong version. The target is a no-op on untagged HEADs so it is safe to run anywhere. Documented in RELEASING.md and CONTRIBUTING.md. Prevents recurrence of gh#3459 (v0.13.0 shipped reporting 0.12.1). Resolves gh#3459 (hq-j6hur.2)
1 parent 29a006d commit 5e13dcc

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
exit 1
4343
fi
4444
45+
- name: Verify tag matches Version constant
46+
run: make check-version-tag
47+
4548
- name: Run GoReleaser
4649
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7
4750
with:

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ For packages with many Dolt-dependent tests, prefer adding
154154
`testutil.EnsureDoltContainerForTestMain()` in a `TestMain` function so all
155155
tests in the package share a single container.
156156

157+
## Releasing
158+
159+
Releases are cut from tags of the form `vX.Y.Z`. See [RELEASING.md](RELEASING.md)
160+
for the full workflow. One guardrail to know about:
161+
162+
- `make check-version-tag` verifies the `Version` constant in
163+
`internal/cmd/version.go` matches the tag at HEAD. The release workflow runs
164+
this before GoReleaser and fails the release on mismatch. Prevents recurrence
165+
of [#3459](https://github.com/steveyegge/gastown/issues/3459). Run it locally
166+
after bumping if you want to catch drift before pushing the tag.
167+
157168
## Questions?
158169

159170
Open an issue for questions about contributing. We're happy to help!

Makefile

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build desktop-build desktop-run install safe-install check-forward-only clean test test-e2e-container check-up-to-date
1+
.PHONY: build desktop-build desktop-run install safe-install check-forward-only check-version-tag clean test test-e2e-container check-up-to-date
22

33
BINARY := gt
44
BINARY_DESKTOP := gt-desktop
@@ -136,6 +136,36 @@ safe-install: check-up-to-date check-forward-only build
136136
@echo "Installed $(BINARY) to $(INSTALL_DIR)/$(BINARY) (daemon NOT restarted)"
137137
@echo "Sessions will pick up new binary on next cycle."
138138

139+
# check-version-tag: Verify that if HEAD is tagged vX.Y.Z, the Version constant
140+
# in internal/cmd/version.go equals X.Y.Z. No-op when HEAD is untagged, so it is
141+
# safe to run on every build but only fails release tag checkouts.
142+
# Prevents recurrence of gh#3459 (v0.13.0 shipped reporting 0.12.1).
143+
check-version-tag:
144+
@TAG=$$(git describe --tags --exact-match HEAD 2>/dev/null || true); \
145+
if [ -z "$$TAG" ]; then \
146+
echo "check-version-tag: HEAD is not a release tag, skipping"; \
147+
exit 0; \
148+
fi; \
149+
case "$$TAG" in \
150+
v[0-9]*) TAG_VERSION=$${TAG#v} ;; \
151+
*) echo "check-version-tag: tag '$$TAG' is not a vX.Y.Z release tag, skipping"; exit 0 ;; \
152+
esac; \
153+
CODE_VERSION=$$(grep -E '^[[:space:]]*Version[[:space:]]*=[[:space:]]*"' internal/cmd/version.go | head -1 | sed 's/.*"\([^"]*\)".*/\1/'); \
154+
if [ -z "$$CODE_VERSION" ]; then \
155+
echo "ERROR: could not parse Version from internal/cmd/version.go"; \
156+
exit 1; \
157+
fi; \
158+
if [ "$$TAG_VERSION" != "$$CODE_VERSION" ]; then \
159+
echo "ERROR: version mismatch between git tag and Version constant"; \
160+
echo " git tag at HEAD: $$TAG (expects Version=$$TAG_VERSION)"; \
161+
echo " internal/cmd/version.go: Version=$$CODE_VERSION"; \
162+
echo ""; \
163+
echo "Run scripts/bump-version.sh before tagging, or re-tag HEAD correctly."; \
164+
echo "See gh#3459 for background."; \
165+
exit 1; \
166+
fi; \
167+
echo "check-version-tag: OK (tag $$TAG matches Version=$$CODE_VERSION)"
168+
139169
clean:
140170
rm -f $(BUILD_DIR)/$(BINARY)
141171

RELEASING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,27 @@ gt daemon stop && gt daemon start
5151

5252
The `release.yml` workflow triggers automatically:
5353

54-
1. **goreleaser** job builds binaries for all platforms and creates the GitHub Release
55-
2. **publish-npm** job publishes to npm (best-effort, `continue-on-error: true`)
54+
1. **Verify tag matches Version constant** — runs `make check-version-tag` and
55+
aborts the release if the pushed tag (`vX.Y.Z`) doesn't match the `Version`
56+
constant in `internal/cmd/version.go`. Prevents recurrence of
57+
[#3459](https://github.com/steveyegge/gastown/issues/3459) where v0.13.0
58+
shipped reporting 0.12.1.
59+
2. **goreleaser** job builds binaries for all platforms and creates the GitHub Release
60+
3. **publish-npm** job publishes to npm (best-effort, `continue-on-error: true`)
5661

5762
Homebrew is NOT updated by the workflow. See below.
5863

64+
### Running the tag/version check locally
65+
66+
```bash
67+
make check-version-tag
68+
```
69+
70+
The target is a no-op on untagged HEADs, so it's safe to run on any checkout.
71+
It only fails when HEAD is tagged `vX.Y.Z` and the `Version` constant doesn't
72+
match. Run it after `scripts/bump-version.sh` and before pushing the tag if you
73+
want to catch drift before CI does.
74+
5975
## Homebrew (homebrew-core)
6076

6177
Gastown is in **homebrew-core** (not a custom tap). The formula lives at:

0 commit comments

Comments
 (0)