Skip to content

Commit 33eca2d

Browse files
authored
fix(ci): use RELEASE_TOKEN for tag creation to bypass rulesets (#339)
Organization-level tag protection rulesets prevent GITHUB_TOKEN from creating tags. This adds support for RELEASE_TOKEN secret (PAT or GitHub App token with bypass permissions) while falling back to GITHUB_TOKEN for backward compatibility. To enable: 1. Create a PAT with 'contents: write' from an org admin account OR create a GitHub App with bypass permissions 2. Add as RELEASE_TOKEN repository secret Resolves tag creation failures with error: 'Cannot create ref due to creations being restricted'
1 parent aff6d35 commit 33eca2d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

.github/workflows/semver-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,23 @@ jobs:
7171
- uses: actions/checkout@v6
7272
with:
7373
fetch-depth: 0
74-
token: ${{ secrets.GITHUB_TOKEN }}
74+
# Use RELEASE_TOKEN (PAT/App token with bypass permissions) if available, fallback to GITHUB_TOKEN
75+
token: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
7576

7677
- name: Python Semantic Release
7778
id: semantic
7879
uses: python-semantic-release/python-semantic-release@v10.5.2
7980
with:
80-
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
# Use RELEASE_TOKEN to bypass tag creation restrictions
82+
github_token: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
8183
verbosity: "2"
8284
# Don't create GitHub release here - we'll create a draft below
8385
vcs_release: "false"
8486

8587
- name: Create draft GitHub release
8688
if: steps.semantic.outputs.released == 'true'
8789
env:
88-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
GH_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
8991
run: |
9092
VERSION="${{ steps.semantic.outputs.version }}"
9193
TAG="v${VERSION}"

0 commit comments

Comments
 (0)