Skip to content

Commit 171bfaa

Browse files
committed
ci(release): allow publish flow on hotfix branches
Permit release preparation and publish workflows from hotfix/* in addition to main, so tag-based hotfix branches can publish patch releases without merging back first.
1 parent 3b9408b commit 171bfaa

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

.github/workflows/docker-publish.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- completed
1515
branches:
1616
- main
17+
- hotfix/**
1718

1819
permissions:
1920
contents: write
@@ -39,13 +40,23 @@ jobs:
3940
CURRENT_REF: ${{ github.ref }}
4041
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
4142
run: |
42-
if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ "$CURRENT_REF" != "refs/heads/main" ]; then
43-
echo "::error::Publish Docker Image must be dispatched from main. Current ref: $CURRENT_REF"
44-
exit 1
43+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
44+
case "$CURRENT_REF" in
45+
refs/heads/main|refs/heads/hotfix/*) ;;
46+
*)
47+
echo "::error::Publish Docker Image must be dispatched from main or hotfix/*. Current ref: $CURRENT_REF"
48+
exit 1
49+
;;
50+
esac
4551
fi
46-
if [ "$EVENT_NAME" = "workflow_run" ] && [ "$HEAD_BRANCH" != "main" ]; then
47-
echo "::error::Publish Docker Image via workflow_run is only allowed from main. Source branch: $HEAD_BRANCH"
48-
exit 1
52+
if [ "$EVENT_NAME" = "workflow_run" ]; then
53+
case "$HEAD_BRANCH" in
54+
main|hotfix/*) ;;
55+
*)
56+
echo "::error::Publish Docker Image via workflow_run is only allowed from main or hotfix/*. Source branch: $HEAD_BRANCH"
57+
exit 1
58+
;;
59+
esac
4960
fi
5061
5162
- uses: actions/checkout@v4

.github/workflows/rust-publish.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ jobs:
3434
contents: write
3535
id-token: write
3636
steps:
37-
- name: Guard main branch for release publish
37+
- name: Guard allowed source branch for release publish
3838
run: |
39-
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
40-
echo "::error::Publish Rust Crates must be run from main. Current ref: ${{ github.ref }}"
41-
exit 1
42-
fi
39+
case "${{ github.ref }}" in
40+
refs/heads/main|refs/heads/hotfix/*) ;;
41+
*)
42+
echo "::error::Publish Rust Crates must be run from main or hotfix/*. Current ref: ${{ github.ref }}"
43+
exit 1
44+
;;
45+
esac
4346
4447
- uses: actions/checkout@v4
4548
with:

.github/workflows/typescript-publish.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ concurrency:
2626

2727
jobs:
2828
guard-main:
29-
name: Guard main branch for publish
29+
name: Guard allowed source branch for publish
3030
runs-on: ubuntu-latest
3131
steps:
32-
- name: Fail if workflow_dispatch is not on main
32+
- name: Fail if workflow_dispatch is not on an allowed branch
3333
run: |
34-
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
35-
echo "::error::Publish TypeScript SDK must be run from main. Current ref: ${{ github.ref }}"
36-
exit 1
37-
fi
34+
case "${{ github.ref }}" in
35+
refs/heads/main|refs/heads/hotfix/*) ;;
36+
*)
37+
echo "::error::Publish TypeScript SDK must be run from main or hotfix/*. Current ref: ${{ github.ref }}"
38+
exit 1
39+
;;
40+
esac
3841
3942
# Run tests before publishing
4043
typescript-integration:

justfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ branch-info:
227227
@echo ""
228228
@echo "Releasing:"
229229
@echo " Stable/Beta/RC: checkout main, run 'just release'"
230+
@echo " Hotfix patch: run 'just release' from hotfix/*"
230231
@echo " Pre-release versions use semver suffixes (e.g. 2.3.0-beta.1)"
231232
@echo " Hotfix: run 'just hotfix' from deployed stable tag"
232233

233-
# Prepare a new release (run from main; use semver pre-release suffixes for beta/rc)
234+
# Prepare a new release (run from main or hotfix/*; use semver pre-release suffixes for beta/rc)
234235
[group('release')]
235236
[confirm('Start release process?')]
236237
release:
@@ -243,10 +244,13 @@ release:
243244
fi
244245

245246
current_branch=$(git rev-parse --abbrev-ref HEAD)
246-
if [ "$current_branch" != "main" ]; then
247-
echo "Error: Releases must be prepared from main (current branch: $current_branch)"
248-
exit 1
249-
fi
247+
case "$current_branch" in
248+
main|hotfix/*) ;;
249+
*)
250+
echo "Error: Releases must be prepared from main or hotfix/* (current branch: $current_branch)"
251+
exit 1
252+
;;
253+
esac
250254

251255
command -v cargo-set-version &>/dev/null || { echo "Install cargo-edit: cargo install cargo-edit"; exit 1; }
252256
command -v git-cliff &>/dev/null || { echo "Install git-cliff: cargo install git-cliff"; exit 1; }
@@ -352,8 +356,9 @@ hotfix name='' base_tag='':
352356
echo ""
353357
echo "Next steps:"
354358
echo " 1. Apply your hotfix commits"
355-
echo " 2. Push and create PR to main"
356-
echo " 3. After merge, run 'just release' on main to publish"
359+
echo " 2. Run 'just release' on this hotfix branch"
360+
echo " 3. Trigger publish workflows from this hotfix branch"
361+
echo " 4. Push and merge hotfix back to main"
357362

358363
# Prepare a new TypeScript SDK release
359364
[group('release')]

0 commit comments

Comments
 (0)