Skip to content

Commit c367225

Browse files
committed
fix(release): stop the bump PR when nothing warrants a release
Now that the types carry `effect`, only the `bump` ones can raise a version, so a cycle of nothing but docs/chore/build/refactor recommends nothing at all. release-it prints "No new version to release", exits 0 and leaves the tree alone. The workflow read that as success and carried on: it pushed a branch at master's head, failed to open a PR against it because there were no commits between the two, and reported that npm and the tag were already out when neither was. Gate the step on the version actually moving and say so in the log instead. The preset comment claimed a build-only release was "still a patch". It isn't, and the check next to it already asserted otherwise.
1 parent b6e42c3 commit c367225

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,25 @@ jobs:
7979
args="$args --dry-run"
8080
fi
8181
82+
before=$(node -p "require('./package.json').version")
8283
pnpm run release $args
83-
84-
echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
84+
after=$(node -p "require('./package.json').version")
85+
86+
echo "version=$after" >> "$GITHUB_OUTPUT"
87+
88+
# Now that the changelog types carry `effect`, only the `bump` ones
89+
# can raise a version, so a cycle of nothing but docs/chore/build/
90+
# refactor commits recommends nothing. release-it prints "No new
91+
# version to release", exits 0 and leaves the tree alone. Without
92+
# this flag the next step would push an empty branch, fail to open a
93+
# PR against it and report that npm and the tag are out when neither
94+
# is. Re-run with the `increment` input if a release was the point.
95+
if [ "$before" = "$after" ]; then
96+
echo "released=false" >> "$GITHUB_OUTPUT"
97+
echo "::notice::No new version to release. Nothing was published or tagged. Dispatch again with an explicit \`increment\` to force one."
98+
else
99+
echo "released=true" >> "$GITHUB_OUTPUT"
100+
fi
85101
86102
# master requires status checks and a fresh commit has none, so the bump
87103
# has to arrive as a PR. Merge commit, not squash: the tag points at the
@@ -99,7 +115,7 @@ jobs:
99115
# npm, the tag and the GitHub release are already out at that point, so
100116
# only the bump on master is waiting.
101117
- name: Land the version bump on master
102-
if: ${{ !inputs.dry-run }}
118+
if: ${{ !inputs.dry-run && steps.release.outputs.released == 'true' }}
103119
env:
104120
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105121
VERSION: ${{ steps.release.outputs.version }}

tools/changelog-preset.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
// test tests are not in `files`
2727
//
2828
// `effect: "changelog"` is the point: those types render without entering the
29-
// bump count, so a release of nothing but `build:` commits is still a patch.
30-
// Only the `bump` types can raise a version.
29+
// bump count. Only the `bump` types can raise a version, so a cycle of nothing
30+
// but `build:` and `docs:` commits recommends no release at all, not a patch.
31+
// release-it handles that by exiting 0 with "No new version to release" and
32+
// touching nothing, and the release workflow's `increment` input is there to
33+
// force a version out anyway when one is wanted.
3134
//
3235
// Breaking changes are not configurable here and don't need to be. The
3336
// preset's writer sets `discard = false` the moment a commit carries a note,

0 commit comments

Comments
 (0)