Skip to content

Commit 6ce5840

Browse files
author
bcode
committed
ci(release): fail tag-push if tag is not reachable from main
Releases must be cut from main. Tagging a feature branch (e.g. when a stacked PR has merged into a parent feature branch but not yet into main) silently produces a release whose contents diverge from the canonical history. Precedent: v0.0.8 / v0.0.9 were tagged from feat/embed-lmnr-key after PR #33 merged into the feature branch (not into main). Main moved on without it and the bcode-laminar package had to be re-landed in PR #39. This guard fails the release workflow early — before any binaries are built or uploaded — when the tag's commit is not an ancestor of origin/main.
1 parent 1b55206 commit 6ce5840

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ jobs:
6060
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
6161
echo "Building tag=${TAG} version=${VERSION}"
6262
63+
- name: Verify tag is reachable from main
64+
# Releases must be cut from `main`. Tagging a feature branch (e.g. when
65+
# a stacked PR has merged into a parent feature branch but not yet into
66+
# `main`) silently produces a release whose contents diverge from the
67+
# canonical history. Precedent: v0.0.8/v0.0.9 were tagged from
68+
# feat/embed-lmnr-key after PR #33 merged into the feature branch
69+
# (not into main); main moved on without it and the bcode-laminar
70+
# package had to be re-landed in PR #39. This guard fails the release
71+
# before any binaries are uploaded.
72+
run: |
73+
git fetch origin main --depth=1
74+
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
75+
echo "::error::Tag ${GITHUB_REF#refs/tags/} points at $GITHUB_SHA which is not reachable from origin/main. Release tags must be cut from main."
76+
exit 1
77+
fi
78+
6379
- name: Setup Bun
6480
uses: ./.github/actions/setup-bun
6581

0 commit comments

Comments
 (0)