Skip to content

Commit b3b4455

Browse files
committed
Add note about repo settings + handle existing branch in prepare release
1 parent 41dcfc4 commit b3b4455

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/prepare-release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
permissions:
2222
contents: write
2323
pull-requests: write
24+
id-token: write
2425
steps:
2526
- uses: actions/checkout@v4
2627
with:
@@ -64,12 +65,25 @@ jobs:
6465
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
6566
echo "Current: $CURRENT_VERSION -> New: $NEW_VERSION"
6667
67-
# Create release branch
68+
# Create release branch (delete if exists from previous failed run)
6869
- name: Create release branch
6970
run: |
7071
BRANCH_NAME="release/v${{ steps.version.outputs.new_version }}"
7172
git config user.name "github-actions[bot]"
7273
git config user.email "github-actions[bot]@users.noreply.github.com"
74+
75+
# Check if branch exists remotely and delete it if it does
76+
if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
77+
echo "Branch $BRANCH_NAME exists remotely, deleting it..."
78+
git push origin --delete $BRANCH_NAME || true
79+
fi
80+
81+
# Check if branch exists locally and delete it if it does
82+
if git show-ref --verify --quiet refs/heads/$BRANCH_NAME; then
83+
echo "Branch $BRANCH_NAME exists locally, deleting it..."
84+
git branch -D $BRANCH_NAME || true
85+
fi
86+
7387
git checkout -b $BRANCH_NAME
7488
echo "Created branch: $BRANCH_NAME"
7589
@@ -92,6 +106,8 @@ jobs:
92106
token: ${{ secrets.GITHUB_TOKEN }}
93107
base: main
94108
branch: release/v${{ steps.version.outputs.new_version }}
109+
delete-branch: false
110+
push-to-fork: false
95111
title: 'Release v${{ steps.version.outputs.new_version }}'
96112
body: |
97113
## Release v${{ steps.version.outputs.new_version }}

RELEASING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ We follow [Semantic Versioning](https://semver.org/) (SemVer):
1212

1313
## Release Workflow
1414

15+
**Important:** Before using the automated release workflow, ensure your repository settings allow GitHub Actions to create pull requests:
16+
17+
1. Go to Repository Settings → Actions → General
18+
2. Under "Workflow permissions", select "Read and write permissions"
19+
3. Check "Allow GitHub Actions to create and approve pull requests"
20+
4. Click "Save"
21+
1522
### Option 1: Automated Release (Recommended)
1623

1724
1. **Prepare Release:**

0 commit comments

Comments
 (0)