Skip to content

Commit 1dce584

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 24e593f commit 1dce584

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 2 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: actions/setup-dotnet@v5
2832
with:
@@ -38,10 +42,25 @@ jobs:
3842
- name: Regenerate from live spec
3943
run: dotnet run --project tools/RoxyDevTools -- generate
4044

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

0 commit comments

Comments
 (0)