-
-
Notifications
You must be signed in to change notification settings - Fork 0
360 lines (310 loc) · 10.1 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
name: Package Release
# A manual workflow, triggered from the UI
on:
workflow_dispatch:
branches:
- main
inputs:
py_release:
description: Python Release
type: boolean
required: false
default: false
py_version:
description: Python Version
default: 0.0.7
js_release:
description: JS Release
type: boolean
required: false
default: false
js_version:
description: JS Version
default: 0.0.29
py_rust_release:
description: Rust-backed Python Release
type: boolean
required: false
default: false
py_rust_version:
description: Rust-backed Python Version
default: 0.0.3
rust_release:
description: Rust Release
type: boolean
required: false
default: false
rust_version:
description: Rust Version
default: 0.4.0
jobs:
commit_versions:
name: Bump Pkg Versions
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
new-sha: ${{ steps.sha.outputs.SHA }}
steps:
- name: Checks out repo with a token that allows pushing to main without PR
uses: actions/checkout@v4
with:
token: ${{ secrets.VERSION_BOT_PAT }}
# Always installing python and bun, quick and so often randomly needed:
- uses: ./.github/actions/install-python
with:
pdm: true
- name: Install Bun, no npm should be needed
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: ./.github/actions/install-rust
if: ${{ inputs.py_rust_release }} || ${{ inputs.rust_release }}
with:
secret_config_toml: ${{ secrets.CUSTOM_RUST_CONFIG_TOML }}
qa: true
# Need to checkout with PAT again, in-case above custom actions checked out with unpermissioned token
- name: Checks out repo with a token that allows pushing to main without PR
uses: actions/checkout@v4
with:
token: ${{ secrets.VERSION_BOT_PAT }}
- name: Update Python version
if: ${{ inputs.py_release }}
run: |
zetch put zetch.config.toml context.static.PY_VERSION ${{ inputs.py_version }}
# Js project
- name: Install js dependencies
if: ${{ inputs.js_release }}
run: |
cd ./js
bun install
- name: Update JS version
if: ${{ inputs.js_release }}
run: |
zetch put zetch.config.toml context.static.JS_VERSION ${{ inputs.js_version }}
- name: Update Rust-backed Python version
if: ${{ inputs.py_rust_release }}
run: |
zetch put zetch.config.toml context.static.PY_RUST_VERSION ${{ inputs.py_rust_version }}
- name: Update Rust version
if: ${{ inputs.rust_release }}
run: |
zetch put zetch.config.toml context.static.RUST_VERSION ${{ inputs.rust_version }}
- uses: ./.github/actions/install-pre-commit
- name: add and format added files with pre-commit
# Running on staged change only as that's all that's needed, || true as don't want it to fail, just modify
run: |
git add . &&
./dev_scripts/test.sh pre_till_success &&
git add .
- name: Commit the new version to the repo
uses: EndBug/add-and-commit@v9
with:
push: true
message: 'chore: bump package versions for release'
author_name: github-actions
author_email: [email protected]
- name: get sha
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo $sha_new
echo "::set-output name=SHA::$sha_new"
- run: echo ${{ steps.sha.outputs.SHA }}
# Rebuild docs each time this is run, note there is currently no versioning in the docs for each of the individually packages, will need to be added when a public package is being properly released
docs:
name: Docs Release
needs: [commit_versions]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
# Basic python always needed:
- uses: ./.github/actions/install-python
with:
pdm: false
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.12'
cache: true
cache-dependency-path: docs/pdm.lock
- name: Install dependencies
run: |
pdm sync -p ./docs
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- uses: ./.github/actions/install-rust
with:
secret_config_toml: ${{ secrets.CUSTOM_RUST_CONFIG_TOML }}
- name: Build docs
run: |
./dev_scripts/docs.sh build
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v4
with:
keep_history: true
target_branch: docs-site
build_dir: site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
py_release:
name: Python Release
needs: [commit_versions]
# Run only if requested:
if: ${{ inputs.py_release }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.12'
cache: true
cache-dependency-path: py/pdm.lock
- name: Publish package publicly to PyPI
run: |
export PDM_PUBLISH_USERNAME='__token__'
export PDM_PUBLISH_PASSWORD='${{ secrets.PYPI_TOKEN }}'
pdm publish -p ./py --repository pypi
- name: Publish the release notes
uses: release-drafter/release-drafter@v5
with:
publish: true
tag: v${{ inputs.py_version }}_py
name: v${{ inputs.py_version }} - Python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
js_release:
name: JS Release
needs: [commit_versions]
# Run only if requested:
if: ${{ inputs.js_release }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install deps, build lib and copy package.json and README.md to dist which is published as
root
run: |
cd js
npm install
npm run build
cp package.json dist/
cp README.md dist/
- name: Publish publicly to NPM
run: |
cd js/dist
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish
- name: Publish the release notes
uses: release-drafter/release-drafter@v5
with:
publish: true
tag: v${{ inputs.js_version }}_js
name: v${{ inputs.js_version }} - JS
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
py_rust_build:
needs: [commit_versions]
# Run only if requested:
if: ${{ inputs.py_rust_release }}
uses: ./.github/workflows/py-rust-build.yml
with:
new-sha: ${{ needs.commit_versions.outputs.new-sha }}
py_rust_release:
name: Rust-backed Python Library Release
# Make needs multiline:
needs: [commit_versions, py_rust_build]
# Run only if requested:
if: ${{ inputs.py_rust_release }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
- name: get dist artifacts built in py_rust_build job
uses: actions/download-artifact@v3
with:
name: py_rust_build_files
path: py_rust/dist
- uses: ./.github/actions/install-python
with:
pdm: false
- run: pip install twine
- name: Make sure release contents seem valid
run: twine check py_rust/dist/*
- name: upload to pypi
run: twine upload py_rust/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Publish the release notes
uses: release-drafter/release-drafter@v5
with:
publish: true
tag: v${{ inputs.py_rust_version }}_py_rs
name: v${{ inputs.py_rust_version }} - Rust-backed Python Library
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
rs_release:
name: Rust Release
needs: [commit_versions]
# Run only if requested:
if: ${{ inputs.rust_release }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
# Basic python always needed:
- uses: ./.github/actions/install-python
with:
pdm: false
- name: Install zetch
run: pip install zetch
- uses: ./.github/actions/install-rust
with:
secret_config_toml: ${{ secrets.CUSTOM_RUST_CONFIG_TOML }}
# Doing again as default checkout might have happened in one of the actions:
- uses: actions/checkout@v4
with:
ref: ${{ needs.commit_versions.outputs.new-sha }}
- name: upload to Crates.io
run: |
cd rust
cargo publish --token ${{ secrets.CRATES_TOKEN }}
- name: Publish the release notes
uses: release-drafter/release-drafter@v5
with:
publish: true
tag: v${{ inputs.rust_version }}_rs
name: v${{ inputs.rust_version }} - Rust
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}