Skip to content

Commit 01ab18b

Browse files
fix(release): keep automatic releases on the default branch
An automatic release pushes its bump to the branch it ran from, but the Homebrew and prebuilt sync always targets the default branch. Dispatched from anywhere else, the bump and the formula land on different branches and main advertises a version whose bump it never received. Fail early and say which branch it is on. Releasing another branch keeps working with an explicit tag, where the bump is already committed and nothing has to guess where it belongs.
1 parent b283434 commit 01ab18b

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,20 @@ jobs:
122122
if: github.event_name == 'workflow_dispatch' && inputs.tag == ''
123123
env:
124124
BUMP: ${{ inputs.bump }}
125+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
125126
run: |
126127
set -euo pipefail
128+
# An automatic release pushes its bump to the branch it ran from, but
129+
# "Sync Homebrew formula + prebuilt binaries" below always targets the
130+
# default branch. From anywhere else those two land on different
131+
# branches, and main ends up advertising a version whose bump it never
132+
# received. Releasing another branch is still possible — with an
133+
# explicit tag, where the bump is already committed and nothing here
134+
# has to guess where it belongs.
135+
if [[ "${GITHUB_REF_NAME}" != "${DEFAULT_BRANCH}" ]]; then
136+
echo "::error::an automatic release (empty tag) runs from ${DEFAULT_BRANCH} only — this run is on ${GITHUB_REF_NAME}. Give an explicit tag to release another branch."
137+
exit 1
138+
fi
127139
git config user.name "github-actions[bot]"
128140
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
129141
version="$(./scripts/next-version.sh --bump "$BUMP" --explain)"

‎RELEASE.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ Cutting 1.0.0 is deliberate, never automatic: on a 0.x line a breaking change mo
144144
minor. Run `scripts/next-version.sh --bump major --allow-zero-major` locally, commit the
145145
bump, and release it with an explicit tag.
146146

147+
An automatic release runs from **`main` only**, and says so if you point it elsewhere. It
148+
pushes its bump to the branch it ran from, while the Homebrew sync always targets `main`;
149+
from another branch those two would land in different places. Release another branch with
150+
an explicit tag, where the bump is already committed.
151+
147152
**Give a tag — release a version that is already committed.** For re-running a release
148153
that published its tag and then died: the job notices the tag exists and builds **from that
149154
tag**, not from whatever `main` has become since, so the assets still match the commit the

0 commit comments

Comments
 (0)