Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
run: python3 .shared-workflows/scripts/release.py rollover --version "$RELEASE_VERSION" --date "$RELEASE_DATE"
- name: Update project version and commit release
if: ${{ !steps.state.outputs.resuming }}
id: prepare
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GH_TOKEN: ${{ github.token }}
Expand All @@ -103,6 +104,12 @@ jobs:
git add CHANGELOG.md "$VERSION_FILE"
git diff --cached --quiet && { echo '::error::No release changes to commit'; exit 1; }
git -c user.name='github-actions[bot]' -c user.email='41898282+github-actions[bot]@users.noreply.github.com' commit -m "chore(release): $RELEASE_VERSION"
# Unprotected default branch: push and publish in this run. Protected: fall back to a release PR.
if git push origin "HEAD:refs/heads/$DEFAULT_BRANCH"; then
echo 'direct=true' >> "$GITHUB_OUTPUT"
exit 0
fi
echo '::notice::Default branch rejected the push; opening a release PR instead.'
branch="release/v$RELEASE_VERSION"
remote_commit=$(git ls-remote origin "refs/heads/$branch" | cut -f1)
if [ -n "$remote_commit" ]; then
Expand All @@ -113,7 +120,7 @@ jobs:
gh pr list --head "$branch" --state open --json url --jq '.[0].url' | grep -q . || \
gh pr create --base "$DEFAULT_BRANCH" --head "$branch" --title "chore(release): $RELEASE_VERSION" --body 'Prepared release; review and merge before publishing the tag.'
- name: Create GitHub Release from changelog notes
if: ${{ steps.state.outputs.resuming }}
if: ${{ steps.state.outputs.resuming || steps.prepare.outputs.direct }}
id: release
env:
GH_TOKEN: ${{ github.token }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to these reusable GitHub Actions workflows are recorded here

## [Unreleased]

### Changed

- Publish in a single run when the default branch accepts the release commit; open a release PR only when branch protection rejects the push.

## [0.1.1] - 2026-10-31

### Fixed
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ caller responsible for events, permissions, checks, and branch protection.
Release callers pass the same SHA as `workflows-ref`: inside `workflow_call`,
`github.workflow_sha` is the caller's commit, not this repository's.

Release callers dispatch `X.Y.Z`: first run opens a release PR; after merging
it, run the same version again to publish the tag and GitHub Release.
Release callers dispatch `X.Y.Z`. If the default branch accepts the bot's push,
the same run commits, tags, and publishes the GitHub Release. If branch
protection rejects it, the run opens a release PR; after merging it, run the same
version again to publish.

## Development

Expand Down
Loading