diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b1fc653..9ffcdbc 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -30,8 +30,10 @@ jobs: run: | set -euo pipefail last_commit=$(git log -1 --pretty=%B) - if printf '%s' "$last_commit" | grep -qi '\[skip-release\]'; then - echo "skipping — commit marked [skip-release]" + # Delegated to bin/should-skip-release so the rule is covered by + # tests/release_skip_test.sh rather than living untested in YAML. + if printf '%s\n' "$last_commit" | sh bin/should-skip-release; then + echo "skipping — commit carries the Skip-Release trailer" echo "skip=true" >> "$GITHUB_OUTPUT" exit 0 fi @@ -73,8 +75,8 @@ jobs: if [ "$current" != "$version" ]; then sed -i "s/\"version\"[[:space:]]*:[[:space:]]*\"$current\"/\"version\": \"$version\"/" "$manifest" git add "$manifest" - # [skip-release] stops this push from re-triggering the tagger. - git commit -m "chore(release): plugin.json version $version [skip-release]" + # The trailer below stops this push from re-triggering the tagger. + git commit -m "chore(release): plugin.json version $version" -m "Skip-Release: true" git push origin HEAD:main echo "bumped $manifest to $version" fi diff --git a/bin/should-skip-release b/bin/should-skip-release new file mode 100755 index 0000000..4a27d76 --- /dev/null +++ b/bin/should-skip-release @@ -0,0 +1,25 @@ +#!/bin/sh +# should-skip-release — reads a commit message on stdin. Exits 0 when the +# release tagger should skip this commit, 1 when it should tag. +# +# Skipping is opt-in via a git trailer: +# +# Skip-Release: true +# +# It is a TRAILER, matched anchored to its own line, deliberately. The first +# version searched the whole message for a bracketed marker as a substring, +# and the very commit that introduced the manifest-bump step described that +# marker in its body — so the tagger read its own documentation as an +# instruction and skipped the release. Success, no tag, no bump, no error +# (run 15, 2026-08-23). A marker you cannot mention without triggering is a +# footgun, not a mechanism. + +set -u + +msg=$(cat) + +if printf '%s\n' "$msg" | grep -qiE '^[[:space:]]*Skip-Release:[[:space:]]*true[[:space:]]*$'; then + exit 0 +fi + +exit 1 diff --git a/tests/release_skip_test.sh b/tests/release_skip_test.sh new file mode 100644 index 0000000..8a3f608 --- /dev/null +++ b/tests/release_skip_test.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Tests for bin/should-skip-release. +# +# The regression these exist for: an unanchored substring match let a commit +# that merely *described* the skip marker skip its own release. + +set -u + +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +SUT="$ROOT/bin/should-skip-release" + +pass=0 +fail=0 + +if [ ! -f "$SUT" ]; then + printf 'FAIL: %s does not exist\n' "$SUT" + exit 1 +fi + +# expect