fix(build): extract VERSION from version.go correctly in the Makefile - #184
Open
swarit-stepsecurity wants to merge 2 commits into
Open
Conversation
The extraction used `sed 's/.*"//;s/".*//'`, whose greedy `.*"` matches through the *closing* quote of `Version = "1.14.0"`, leaving nothing for the second expression to trim. VERSION has therefore been the empty string, and its only consumers — the two MSI targets — accept that silently: `wix build` gets `-d Version=` and the package is written to dist/stepsecurity-dev-machine-guard--x64.msi. Only local `make build-msi-*` runs are affected. CI builds MSIs in test-build.yml by invoking `wix build` directly with the version resolved in the build job, and release.yml derives the tag with its own (working) expression, so no shipped artifact carries the empty version. Replace it with a single anchored expression: matching `Version =` rules out other lines that merely mention Version, and `[^"]*` cannot run past the closing quote. Both MSI recipes now assert VERSION is non-empty, so a future breakage stops the build instead of producing an unversioned package the way this one did.
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.
Makefile:3derivedVERSIONwithsed 's/.*"//;s/".*//'. The greedy.*"matches through the closing quote ofVersion = "1.14.0", so the first expression consumes the whole value and the second has nothing to trim —VERSIONhas been the empty string.Its only consumers are the two MSI targets, and both accept empty silently:
Blast radius is local only. CI builds MSIs in
test-build.ymlby callingwix builddirectly with the version resolved in thebuildjob, andrelease.yml:34derives the tag with its own working expression (sed 's/.*"\(.*\)".*/\1/'). No shipped artifact carries the empty version — this only bites someone runningmake build-msi-*on their machine.Fix
One anchored expression:
[^"]*cannot run past the closing quote, and matchingVersion =rather than bareVersionmeans a doc comment or a futureVersionString-style line can't be picked up bygrep -m1.Both MSI recipes now assert
VERSIONis non-empty. That's the part that actually matters: the reason this went unnoticed is that an empty value produced a plausible-looking build rather than an error.Verified
make -p | grep '^VERSION'→VERSION := 1.14.0make -n build-msi-amd64→-d Version=1.14.0,-out dist/stepsecurity-dev-machine-guard-1.14.0-x64.msimake build-msi-amd64exit 1 witherror: no Version found in internal/buildinfo/version.gomake test/make smokein CI evaluate line 3 at parse time and are unaffected either way.No changelog entry — build tooling only, no user-facing change.