Skip to content

Commit a1e2598

Browse files
committed
ci: use GitHub App for releases
1 parent deeb775 commit a1e2598

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

.github/RELEASE_APP.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Release GitHub App
2+
3+
Releases use a GitHub App installation token instead of a personal access
4+
token. The App token is short-lived and lets Python Semantic Release commit the
5+
version and changelog, push the release tag, and create the GitHub release.
6+
7+
## Organization setup
8+
9+
1. Create a GitHub App owned by the `Python-roborock` organization.
10+
2. Disable webhooks and grant the App **Contents: Read and write** repository
11+
permission. No other optional repository or organization permissions are
12+
required.
13+
3. Install the App only on the `python-roborock` repository.
14+
4. In the `main` branch protection settings, add the App to **Allow specified
15+
actors to bypass required pull requests**. Without this bypass,
16+
semantic-release cannot commit the generated release files back to `main`.
17+
5. Add the App's client ID as the repository variable
18+
`RELEASE_APP_CLIENT_ID`.
19+
6. Generate a private key for the App and save the complete PEM file as the
20+
`release` environment secret `RELEASE_APP_PRIVATE_KEY`.
21+
22+
After a successful release using the App, remove the old maintainer-owned
23+
`GH_TOKEN` repository secret.

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,20 @@ jobs:
127127
with:
128128
fetch-depth: 0
129129
persist-credentials: false
130+
- name: Create release GitHub App token
131+
id: release-token
132+
uses: actions/create-github-app-token@v3
133+
with:
134+
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
135+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
136+
permission-contents: write
130137
- name: Python Semantic Release
131138
id: release
132139
uses: python-semantic-release/python-semantic-release@v10.5.3
133140
with:
134-
github_token: ${{ secrets.GH_TOKEN }}
141+
# The release App is allowed to bypass the pull-request requirement so
142+
# semantic-release can commit the version and changelog back to main.
143+
github_token: ${{ steps.release-token.outputs.token }}
135144
changelog: true
136145

137146
- name: Publish package distributions to PyPI
@@ -148,5 +157,5 @@ jobs:
148157
uses: python-semantic-release/publish-action@v10.5.3
149158
if: steps.release.outputs.released == 'true'
150159
with:
151-
github_token: ${{ secrets.GITHUB_TOKEN }}
160+
github_token: ${{ steps.release-token.outputs.token }}
152161
tag: ${{ steps.release.outputs.tag }}

0 commit comments

Comments
 (0)