-
Notifications
You must be signed in to change notification settings - Fork 1
413 lines (345 loc) · 12.4 KB
/
release.yml
File metadata and controls
413 lines (345 loc) · 12.4 KB
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
id-token: write
jobs:
notify-start:
name: Initialize Slack Notification
runs-on: ubuntu-latest
outputs:
slack_ts: ${{ steps.slack.outputs.ts }}
steps:
- name: Post initial Slack message
id: slack
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "Release ${{ github.ref_name }} started"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "*Release ${{ github.ref_name }}*\n\n:hourglass: Running tests...\n:white_square: Creating release...\n:white_square: Publishing SDKs..."
- type: "context"
elements:
- type: "mrkdwn"
text: "Triggered by ${{ github.actor }} | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
- name: Save Slack timestamp to artifact
run: |
mkdir -p slack-data
echo "${{ steps.slack.outputs.ts }}" > slack-data/message_ts.txt
echo "${{ github.ref_name }}" > slack-data/version.txt
- name: Upload Slack data
uses: actions/upload-artifact@v4
with:
name: slack-notification-data
path: slack-data/
retention-days: 1
detect-prerelease:
name: Detect Pre-release
runs-on: ubuntu-latest
outputs:
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
npm_tag: ${{ steps.check.outputs.npm_tag }}
steps:
- name: Check tag format
id: check
run: |
TAG="${{ github.ref_name }}"
if [[ "$TAG" =~ -alpha$ ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "npm_tag=alpha" >> $GITHUB_OUTPUT
echo "Detected pre-release: true (alpha)"
elif [[ "$TAG" =~ -beta$ ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "npm_tag=beta" >> $GITHUB_OUTPUT
echo "Detected pre-release: true (beta)"
elif [[ "$TAG" =~ -rc$ ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "npm_tag=rc" >> $GITHUB_OUTPUT
echo "Detected pre-release: true (rc)"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "npm_tag=latest" >> $GITHUB_OUTPUT
echo "Detected stable release (npm tag: latest)"
fi
test-node:
name: Test Node.js SDK
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/node
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
run_install: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm --filter iii-sdk exec tsc --noEmit
- name: Build
run: pnpm build
test-python:
name: Test Python SDK
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/python/iii
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Setup uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev
- name: Lint
run: uv run ruff check src
- name: Type check
run: uv run mypy src
- name: Start III Engine
working-directory: .
run: |
curl -fsSl https://raw.githubusercontent.com/iii-hq/iii/main/install.sh | sh
which iii
iii -v
iii --config "${{ github.workspace }}/.github/engine-config/test-config.yml" > /tmp/iii-engine.log 2>&1 &
echo $! > /tmp/iii-engine.pid
echo "Waiting for III Engine on port 49134..."
for i in $(seq 1 30); do
if nc -z 127.0.0.1 49134 2>/dev/null; then
echo "III Engine is ready!"
exit 0
fi
echo " attempt $i/30..."
sleep 2
done
echo "Engine did not become ready. Logs:"
tail -n 50 /tmp/iii-engine.log || true
exit 1
- name: Run tests
run: uv run pytest -q
- name: Stop III Engine
if: always()
run: |
if [ -f /tmp/iii-engine.pid ]; then
kill "$(cat /tmp/iii-engine.pid)" || true
fi
test-rust:
name: Test Rust SDK
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/rust/iii
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry & build
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Start III Engine
working-directory: .
run: |
curl -fsSl https://raw.githubusercontent.com/iii-hq/iii/main/install.sh | sh
which iii
iii --version
iii -v
iii --config "${{ github.workspace }}/.github/engine-config/test-config.yml" > /tmp/iii-engine.log 2>&1 &
echo $! > /tmp/iii-engine.pid
echo "Waiting for III Engine on port 49134..."
for i in $(seq 1 30); do
if nc -z 127.0.0.1 49134 2>/dev/null; then
echo "III Engine is ready!"
exit 0
fi
echo " attempt $i/30..."
sleep 2
done
echo "Engine did not become ready. Logs:"
tail -n 50 /tmp/iii-engine.log || true
exit 1
- name: Run tests
run: cargo test --all-features --quiet
- name: Stop III Engine
if: always()
run: |
if [ -f /tmp/iii-engine.pid ]; then
kill "$(cat /tmp/iii-engine.pid)" || true
fi
create-release:
name: Create Release
needs: [notify-start, detect-prerelease, test-node, test-python, test-rust]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.III_CI_APP_ID }}
private-key: ${{ secrets.III_CI_APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ steps.generate_token.outputs.token }}
draft: false
prerelease: ${{ needs.detect-prerelease.outputs.is_prerelease == 'true' }}
generate_release_notes: true
- name: Update Slack - Tests passed, release created
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.update
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
ts: ${{ needs.notify-start.outputs.slack_ts }}
text: "Release ${{ github.ref_name }} in progress"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "*Release ${{ github.ref_name }}*\n\n:white_check_mark: Tests passed (Node, Python, Rust)\n:white_check_mark: Release created\n:hourglass: Publishing SDKs..."
- type: "context"
elements:
- type: "mrkdwn"
text: "Triggered by ${{ github.actor }} | <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|View Release>"
publish-node:
name: Publish Node SDK
needs: [detect-prerelease, create-release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
working-directory: packages/node
run: pnpm install --frozen-lockfile
- name: Build SDK
working-directory: packages/node/iii
run: pnpm build
- name: Publish to npm
working-directory: packages/node/iii
run: pnpm publish --access public --no-git-checks --tag ${{ needs.detect-prerelease.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-python:
name: Publish Python SDK
needs: [create-release]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build tools
run: pip install build
- name: Build package
working-directory: packages/python/iii
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: packages/python/iii/dist/
password: ${{ secrets.PYPI_API_TOKEN }}
publish-rust:
name: Publish Rust SDK
needs: [create-release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry & build
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/rust/iii
- name: Publish to crates.io
working-directory: packages/rust/iii
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
notify-complete:
name: Update Release Status
needs: [notify-start, publish-node, publish-python, publish-rust]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check results
id: results
run: |
NODE_RESULT='${{ needs.publish-node.result }}'
PYTHON_RESULT='${{ needs.publish-python.result }}'
RUST_PUBLISH_RESULT='${{ needs.publish-rust.result }}'
NODE_ICON="white_check_mark"
PYTHON_ICON="white_check_mark"
RUST_PUBLISH_ICON="white_check_mark"
if [ "$NODE_RESULT" != "success" ]; then NODE_ICON="x"; fi
if [ "$PYTHON_RESULT" != "success" ]; then PYTHON_ICON="x"; fi
if [ "$RUST_PUBLISH_RESULT" != "success" ]; then RUST_PUBLISH_ICON="x"; fi
echo "node_icon=$NODE_ICON" >> $GITHUB_OUTPUT
echo "python_icon=$PYTHON_ICON" >> $GITHUB_OUTPUT
echo "rust_publish_icon=$RUST_PUBLISH_ICON" >> $GITHUB_OUTPUT
- name: Update Slack - Release Complete
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.update
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
ts: ${{ needs.notify-start.outputs.slack_ts }}
text: "Release ${{ github.ref_name }} complete"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "*Release ${{ github.ref_name }}*\n\n:white_check_mark: Tests passed (Node, Python, Rust)\n:white_check_mark: Release created\n:${{ steps.results.outputs.node_icon }}: Node SDK published to npm\n:${{ steps.results.outputs.python_icon }}: Python SDK published to PyPI\n:${{ steps.results.outputs.rust_publish_icon }}: Rust SDK published to crates.io"
- type: "context"
elements:
- type: "mrkdwn"
text: "Triggered by ${{ github.actor }} | <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|View Release>"