Skip to content

Commit 344bb36

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 041b57c commit 344bb36

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,28 @@ jobs:
4040
- name: Sync docs from spec
4141
run: node scripts/sync-docs.mjs
4242

43-
- name: Check if spec changed
43+
# Compare against the last RELEASED tag, never against the working tree.
44+
# "Did anything change since the last commit" is the wrong question: commit a
45+
# regeneration by hand and the next run sees a clean tree, reports success and
46+
# silently skips every publish step below, leaving the registry behind forever.
47+
# The tag cannot lie, because whatever is published is what that tag built.
48+
# The spec is the only generator input, so it is the only thing worth diffing;
49+
# a generator version bump changes the output without touching the spec and is
50+
# released deliberately through workflow_dispatch.
51+
- name: Is the published release built from the current spec?
4452
id: diff
4553
run: |
46-
OLD=$(git show HEAD:specs/openapi.json | jq -cS '{paths, components}')
47-
NEW=$(jq -cS '{paths, components}' specs/openapi.json)
48-
if [ "$OLD" = "$NEW" ]; then
49-
echo "changed=false" >> $GITHUB_OUTPUT
54+
LAST=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true)
55+
if [ -z "$LAST" ]; then
56+
echo "changed=true" >> "$GITHUB_OUTPUT"
57+
exit 0
58+
fi
59+
git show "$LAST:specs/openapi.json" | jq -cS . > "$RUNNER_TEMP/released-spec.json"
60+
jq -cS . specs/openapi.json > "$RUNNER_TEMP/current-spec.json"
61+
if cmp -s "$RUNNER_TEMP/released-spec.json" "$RUNNER_TEMP/current-spec.json"; then
62+
echo "changed=false" >> "$GITHUB_OUTPUT"
5063
else
51-
echo "changed=true" >> $GITHUB_OUTPUT
64+
echo "changed=true" >> "$GITHUB_OUTPUT"
5265
fi
5366
5467
- name: Lint

0 commit comments

Comments
 (0)