Skip to content

Commit fa99a75

Browse files
committed
fix: keep semver validation at release preflight
Codex review flagged that removing the per-PR gate also dropped the only semver-format check. Validate the version in release.yml preflight, before any images are pushed, and reword the README to match the actual procedure (bump in a PR before dispatching).
1 parent 75d4c7b commit fa99a75

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ jobs:
2929
echo "releases are cut from main; this run is on $GITHUB_REF" >&2
3030
exit 1
3131
fi
32-
tag="v$(jq -r .version cli/package.json)"
32+
version=$(jq -r .version cli/package.json)
33+
case "$version" in
34+
[0-9]*.[0-9]*.[0-9]*) ;;
35+
*) echo "cli/package.json version must be semver, got $version" >&2; exit 1 ;;
36+
esac
37+
tag="v$version"
3338
if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" > /dev/null 2>&1; then
3439
echo "$tag is already released; bump cli/package.json before releasing again" >&2
3540
exit 1

cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ This package is published to npm as `@yc-software/qm`, with npm provenance attes
2222
building workflow. A release is one dispatch of `.github/workflows/release.yml` from
2323
`main`: it signs and pushes the first-party images, publishes the package pinning their
2424
digests, and then tags `v<version>` and creates the GitHub release with the resolved
25-
digests attached. The version comes from `cli/package.json`, bumped when a release is cut rather than by
26-
every pull request that touches the package; a tag that already exists stops the release
27-
rather than moving. The checked-in image manifest is a sentinel that
25+
digests attached. The version comes from `cli/package.json`, bumped in a PR before dispatching a release
26+
rather than by every pull request that touches the package; a tag that already exists
27+
stops the release rather than moving. The checked-in image manifest is a sentinel that
2828
a deployment overrides with real digests. The packed-artifact test exercises the consumer
2929
path locally.
3030

test/release-workflows.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ test("one dispatchable workflow drives the whole release, main-only and in order
134134
test("the release refuses a tag it already published and writes the tag last", () => {
135135
const workflow = readFileSync(".github/workflows/release.yml", "utf8");
136136

137-
assert.match(workflow, /tag="v\$\(jq -r \.version cli\/package\.json\)"/);
137+
assert.match(workflow, /version=\$\(jq -r \.version cli\/package\.json\)/);
138+
assert.match(workflow, /cli\/package\.json version must be semver/);
139+
assert.match(workflow, /tag="v\$version"/);
138140
assert.match(workflow, /is already released; bump cli\/package\.json before releasing again/);
139141
assert.ok(
140142
workflow.indexOf("already released") < workflow.indexOf("gh release create"),

0 commit comments

Comments
 (0)