Skip to content

Commit ab57b23

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 e15fb07 commit ab57b23

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
- uses: actions/checkout@v7
2424
with:
2525
token: ${{ secrets.GITHUB_TOKEN }}
26+
# Release tags are the ledger the gate below reads. The default shallow
27+
# checkout fetches none of them, which would make every run look like a
28+
# first release.
29+
fetch-depth: 0
2630

2731
- uses: astral-sh/setup-uv@v7
2832
with:
@@ -35,13 +39,28 @@ jobs:
3539
- name: Regenerate SDK from live spec
3640
run: uv run python generate.py
3741

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

0 commit comments

Comments
 (0)