Skip to content

Commit 6f23c19

Browse files
committed
ci: allow scoped maintenance releases
1 parent e26b6ee commit 6f23c19

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ jobs:
6767
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
6868
echo "Building tag=${TAG} version=${VERSION}"
6969
70-
- name: Verify tag is reachable from main
71-
# Releases must be cut from `main`. Tagging a feature branch (e.g. when
72-
# a stacked PR has merged into a parent feature branch but not yet into
73-
# `main`) silently produces a release whose contents diverge from the
74-
# canonical history. Precedent: v0.0.8/v0.0.9 were tagged from
70+
- name: Verify tag is reachable from an approved release branch
71+
# Stable releases must be cut from `main`. A narrowly named
72+
# `vX.Y.Z-hotfixN` prerelease may instead come from its matching
73+
# `release/vX.Y.Z` maintenance branch. Other feature-branch tags fail
74+
# before binaries are uploaded. Precedent: v0.0.8/v0.0.9 were tagged from
7575
# feat/embed-lmnr-key after PR #33 merged into the feature branch
7676
# (not into main); main moved on without it and the bcode-laminar
7777
# package had to be re-landed in PR #39. This guard fails the release
@@ -85,15 +85,23 @@ jobs:
8585
env:
8686
TAG: ${{ steps.ver.outputs.tag }}
8787
run: |
88-
git fetch origin main --depth=1
88+
git fetch origin main "refs/heads/release/*:refs/remotes/origin/release/*"
8989
TAG_SHA=$(git rev-parse -q --verify "refs/tags/${TAG}^{commit}") || {
90-
echo "::error::Tag ${TAG} does not exist locally. Create the tag on a main commit first (e.g. \`gh release create ${TAG} --target main\`), then re-run."
90+
echo "::error::Tag ${TAG} does not exist locally. Create it on main or the matching release/vX.Y.Z maintenance branch, then re-run."
9191
exit 1
9292
}
93-
if ! git merge-base --is-ancestor "$TAG_SHA" origin/main; then
94-
echo "::error::Tag ${TAG} points at $TAG_SHA which is not reachable from origin/main. Release tags must be cut from main."
95-
exit 1
93+
if git merge-base --is-ancestor "$TAG_SHA" origin/main; then
94+
exit 0
95+
fi
96+
if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)-hotfix[0-9]+$ ]]; then
97+
RELEASE_REF="origin/release/v${BASH_REMATCH[1]}"
98+
if git show-ref --verify --quiet "refs/remotes/${RELEASE_REF}" &&
99+
git merge-base --is-ancestor "$TAG_SHA" "$RELEASE_REF"; then
100+
exit 0
101+
fi
96102
fi
103+
echo "::error::Tag ${TAG} points at $TAG_SHA outside main or its matching release/vX.Y.Z maintenance branch."
104+
exit 1
97105
98106
- name: Setup Bun
99107
uses: ./.github/actions/setup-bun

0 commit comments

Comments
 (0)