Skip to content

Commit 012237f

Browse files
committed
fix(release): gate on the last released tag, not the working tree
The gate asked whether anything moved since the last commit, so a regeneration committed by hand left a clean tree and the next scheduled run reported success while skipping every publish step. Nothing alerts, because skipping is what the gate exists to do. Compare the spec at the last release tag against the freshly regenerated copy instead, which answers whether what is published was built from the current spec. This needs fetch-depth 0, since the default checkout fetches no tags and a missing tag reads as never released.
1 parent 3f765bb commit 012237f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,25 @@ jobs:
3030
- name: Regenerate from spec
3131
run: go run ./tools/roxygen generate
3232

33-
- name: Detect changes
33+
# Compare against the last RELEASED tag, never against the working tree.
34+
# "Did anything change since the last commit" is the wrong question: commit a
35+
# regeneration by hand and the next run sees a clean tree, reports success and
36+
# silently skips every publish step below, leaving the registry behind forever.
37+
# The tag cannot lie, because whatever is published is what that tag built.
38+
# The spec is the only generator input, so it is the only thing worth diffing;
39+
# a generator version bump changes the output without touching the spec and is
40+
# released deliberately through workflow_dispatch.
41+
- name: Is the published release built from the current spec?
3442
id: diff
3543
run: |
36-
if git diff --quiet -- specs/openapi.json roxyapi.gen.go roxy.gen.go README.md AGENTS.md docs/llms-full.txt; then
44+
LAST=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true)
45+
if [ -z "$LAST" ]; then
46+
echo "changed=true" >> "$GITHUB_OUTPUT"
47+
exit 0
48+
fi
49+
git show "$LAST:specs/openapi.json" | jq -cS . > "$RUNNER_TEMP/released-spec.json"
50+
jq -cS . specs/openapi.json > "$RUNNER_TEMP/current-spec.json"
51+
if cmp -s "$RUNNER_TEMP/released-spec.json" "$RUNNER_TEMP/current-spec.json"; then
3752
echo "changed=false" >> "$GITHUB_OUTPUT"
3853
else
3954
echo "changed=true" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)