Skip to content

Commit dccc8e5

Browse files
committed
ci: use release bot for CLI publishing
1 parent ef19a65 commit dccc8e5

3 files changed

Lines changed: 59 additions & 5 deletions

File tree

.github/workflows/backfill-release-assets.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- validate-release-tag
3333
runs-on: ${{ matrix.os }}
3434
timeout-minutes: 30
35+
environment: release
3536
permissions:
3637
contents: write
3738
strategy:
@@ -46,6 +47,13 @@ jobs:
4647
asset_arch: arm64
4748

4849
steps:
50+
- name: Create release bot token
51+
id: release-bot
52+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
53+
with:
54+
app-id: ${{ vars.PUTIO_RELEASE_BOT_APP_ID }}
55+
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
56+
permission-contents: write
4957
- name: Check out repository
5058
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5159
with:
@@ -96,6 +104,7 @@ jobs:
96104
- name: Upload binary assets to the GitHub release
97105
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
98106
with:
107+
token: ${{ steps.release-bot.outputs.token }}
99108
tag_name: ${{ inputs.tag_name }}
100109
files: |
101110
.artifacts/release/*
@@ -106,10 +115,18 @@ jobs:
106115
- validate-release-tag
107116
runs-on: windows-latest
108117
timeout-minutes: 30
118+
environment: release
109119
permissions:
110120
contents: write
111121

112122
steps:
123+
- name: Create release bot token
124+
id: release-bot
125+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
126+
with:
127+
app-id: ${{ vars.PUTIO_RELEASE_BOT_APP_ID }}
128+
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
129+
permission-contents: write
113130
- name: Check out repository
114131
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
115132
with:
@@ -155,6 +172,7 @@ jobs:
155172
- name: Upload binary assets to the GitHub release
156173
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
157174
with:
175+
token: ${{ steps.release-bot.outputs.token }}
158176
tag_name: ${{ inputs.tag_name }}
159177
files: |
160178
.artifacts/release/*

.github/workflows/ci.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,20 @@ jobs:
6060
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
6161

6262
steps:
63+
- name: Create release bot token
64+
id: release-bot
65+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
66+
with:
67+
app-id: ${{ vars.PUTIO_RELEASE_BOT_APP_ID }}
68+
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
69+
permission-contents: write
70+
permission-issues: write
71+
permission-pull-requests: write
6372
- name: Check out repository
6473
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
6574
with:
6675
fetch-depth: 0
76+
token: ${{ steps.release-bot.outputs.token }}
6777

6878
- name: Set up Node.js
6979
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
@@ -91,12 +101,12 @@ jobs:
91101
@semantic-release/git
92102
conventional-changelog-conventionalcommits
93103
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
GITHUB_TOKEN: ${{ steps.release-bot.outputs.token }}
95105
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
96-
GIT_AUTHOR_NAME: devsputio
97-
GIT_AUTHOR_EMAIL: devs@put.io
98-
GIT_COMMITTER_NAME: devsputio
99-
GIT_COMMITTER_EMAIL: devs@put.io
106+
GIT_AUTHOR_NAME: ${{ steps.release-bot.outputs.app-slug }}[bot]
107+
GIT_AUTHOR_EMAIL: ${{ steps.release-bot.outputs.app-slug }}[bot]@users.noreply.github.com
108+
GIT_COMMITTER_NAME: ${{ steps.release-bot.outputs.app-slug }}[bot]
109+
GIT_COMMITTER_EMAIL: ${{ steps.release-bot.outputs.app-slug }}[bot]@users.noreply.github.com
100110

101111
build-unix-binaries:
102112
if: needs.release.outputs.new_release_published == 'true'
@@ -105,6 +115,7 @@ jobs:
105115
- release
106116
runs-on: ${{ matrix.os }}
107117
timeout-minutes: 30
118+
environment: release
108119
permissions:
109120
contents: write
110121
strategy:
@@ -119,6 +130,13 @@ jobs:
119130
asset_arch: arm64
120131

121132
steps:
133+
- name: Create release bot token
134+
id: release-bot
135+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
136+
with:
137+
app-id: ${{ vars.PUTIO_RELEASE_BOT_APP_ID }}
138+
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
139+
permission-contents: write
122140
- name: Check out repository
123141
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
124142
with:
@@ -167,6 +185,7 @@ jobs:
167185
- name: Upload binary assets to the GitHub release
168186
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
169187
with:
188+
token: ${{ steps.release-bot.outputs.token }}
170189
tag_name: ${{ needs.release.outputs.new_release_git_tag }}
171190
files: |
172191
.artifacts/release/*
@@ -178,10 +197,18 @@ jobs:
178197
- release
179198
runs-on: windows-latest
180199
timeout-minutes: 30
200+
environment: release
181201
permissions:
182202
contents: write
183203

184204
steps:
205+
- name: Create release bot token
206+
id: release-bot
207+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
208+
with:
209+
app-id: ${{ vars.PUTIO_RELEASE_BOT_APP_ID }}
210+
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
211+
permission-contents: write
185212
- name: Check out repository
186213
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
187214
with:
@@ -225,6 +252,7 @@ jobs:
225252
- name: Upload binary assets to the GitHub release
226253
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
227254
with:
255+
token: ${{ steps.release-bot.outputs.token }}
228256
tag_name: ${{ needs.release.outputs.new_release_git_tag }}
229257
files: |
230258
.artifacts/release/*

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ pnpm run build:sea
4747
pnpm run verify:sea
4848
```
4949

50+
## Release Publishing
51+
52+
GitHub Actions publishes from `main` through the protected `release` Environment.
53+
54+
Keep `NPM_TOKEN`, `PUTIO_RELEASE_BOT_APP_ID`, and `PUTIO_RELEASE_BOT_PRIVATE_KEY` in that Environment with required reviewers and prevent self-review enabled. Pull request checks stay secretless and only run verify jobs.
55+
56+
Release GitHub writes use `putio-release-bot` for version sync commits, `v*` tags, GitHub Releases, and binary asset uploads. Trusted put.io team members may push directly to `main`, but repository rules should block outsiders, force-pushes, and branch deletes where GitHub plan support allows.
57+
5058
## Development Notes
5159

5260
- `verify` is the repository delivery gate.

0 commit comments

Comments
 (0)