-
Notifications
You must be signed in to change notification settings - Fork 1k
389 lines (334 loc) · 12.4 KB
/
Copy pathrelease.yml
File metadata and controls
389 lines (334 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
name: Release
run-name: ${{ format('Release {0} [{1}]', github.event.inputs.release_tag, github.event.inputs.dry_run == 'true' && 'dry-run' || 'live') }}
on:
workflow_dispatch:
inputs:
release_tag:
description: "Release tag (e.g. v1.9.0)"
required: true
dry_run:
description: "Run in dry-run mode"
required: true
type: boolean
default: true
release_crates:
description: "Release crates.io packages"
required: true
type: boolean
default: false
release_csharp:
description: "Release C# SDK"
required: true
type: boolean
default: false
release_cpp:
description: "Release C++ bindings"
required: true
type: boolean
default: false
release_npm:
description: "Release NPM package"
required: true
type: boolean
default: false
release_docker:
description: "Release Docker container"
required: true
type: boolean
default: false
update_mirror_latest_version:
description: "Update S3 mirror latest-version marker"
required: true
type: boolean
default: false
permissions:
contents: write
packages: write
concurrency:
group: manual-release-${{ inputs.release_tag }}${{ inputs.dry_run && format('-dry-run-{0}', github.run_id) || '' }}
cancel-in-progress: true
jobs:
# This job runs before all of our release jobs. If there is a release problem we should
# try to fail during this step to prevent partial releases.
build-cargo-release:
runs-on: spacetimedb-new-runner-2
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Cache cargo
uses: swatinem/rust-cache@v2
with:
workspaces: ./
- name: Install cargo-release
run: |
cargo install --path tools/release
# ensure the binary exists
which cargo-release
# copy it into a sharable directory
mkdir -p shared-bin
cp "$(which cargo-release)" shared-bin/
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: cargo-release-bin
path: shared-bin/
release-crates:
needs: build-cargo-release
runs-on: spacetimedb-new-runner-2
if: ${{ inputs.release_crates }}
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag }}
submodules: recursive
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Download cargo-release
uses: actions/download-artifact@v4
with:
name: cargo-release-bin
path: ./shared-bin
- name: Make binary executable and on PATH
run: |
chmod +x ./shared-bin/cargo-release
echo "$PWD/shared-bin" >> "$GITHUB_PATH"
# TODO: dry-run via publishing to a local registry: https://doc.rust-lang.org/cargo/reference/registries.html
- name: Run release (dry-run)
if: ${{ inputs.dry_run }}
# NOTE: This will print a warning that `cargo-release release crates` dry runs are not supported
run: cargo-release release crates ${{ github.event.inputs.release_tag }} --dry-run
- name: Run release
if: ${{ !inputs.dry_run }}
run: cargo-release release crates ${{ github.event.inputs.release_tag }}
release-csharp:
needs: build-cargo-release
runs-on: spacetimedb-new-runner-2
if: ${{ inputs.release_csharp }}
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag }}
submodules: recursive
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Download cargo-release
uses: actions/download-artifact@v4
with:
name: cargo-release-bin
path: ./shared-bin
- name: Make binary executable and on PATH
run: |
chmod +x ./shared-bin/cargo-release
echo "$PWD/shared-bin" >> "$GITHUB_PATH"
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
global-json-path: global.json
- name: Install NuGet
shell: bash
run: |
sudo apt install -y mono-complete
mkdir bin
cd bin
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
# We're on linux, so we need to do a mono dance to make NuGet invocations look the same as they would on e.g. windows
mv nuget.exe nuget-mono.exe
cat <<'EOF' | sed 's/^ *//' >nuget
#!/bin/bash
DIR="$(dirname "$(readlink -f "$0")")"
mono "$DIR/nuget-mono.exe" "$@"
EOF
chmod +x nuget
echo "$PWD" >> $GITHUB_PATH
- name: Setup SSH key for Unity SDK repo
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.UNITY_SDK_DEPLOY_KEY }}
- name: Configure git
run: |
git config --global user.name "Release Bot"
git config --global user.email "no-reply@clockworklabs.io"
# Remove any HTTPS to SSH conversion set by checkout action
git config --global --unset-all url.https://github.com/.insteadOf || true
# Ensure SSH is used instead of HTTPS for GitHub
git config --global url."git@github.com:".insteadOf "https://github.com/"
# Verify configuration
echo "Git URL rewrite config:"
git config --global --get-regexp url
- name: Run C# SDK release (dry-run)
if: ${{ inputs.dry_run }}
run: cargo-release release csharp ${{ github.event.inputs.release_tag }} --dry-run
- name: Run C# SDK release
if: ${{ !inputs.dry_run }}
run: cargo-release release csharp ${{ github.event.inputs.release_tag }}
release-cpp:
needs: build-cargo-release
runs-on: spacetimedb-new-runner-2
if: ${{ inputs.release_cpp }}
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag }}
submodules: recursive
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Download cargo-release
uses: actions/download-artifact@v4
with:
name: cargo-release-bin
path: ./shared-bin
- name: Make binary executable and on PATH
run: |
chmod +x ./shared-bin/cargo-release
echo "$PWD/shared-bin" >> "$GITHUB_PATH"
- name: Setup SSH key for C++ SDK repo
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.CPP_SDK_DEPLOY_KEY }}
- name: Configure git
run: |
git config --global user.name "Release Bot"
git config --global user.email "no-reply@clockworklabs.io"
# Remove any HTTPS to SSH conversion set by checkout action
git config --global --unset-all url.https://github.com/.insteadOf || true
# Ensure SSH is used instead of HTTPS for GitHub
git config --global url."git@github.com:".insteadOf "https://github.com/"
# Verify configuration
echo "Git URL rewrite config:"
git config --global --get-regexp url
- name: Run C++ SDK release (dry-run)
if: ${{ inputs.dry_run }}
run: cargo-release release cpp ${{ github.event.inputs.release_tag }} --dry-run
- name: Run C++ SDK release
if: ${{ !inputs.dry_run }}
run: cargo-release release cpp ${{ github.event.inputs.release_tag }}
release-npm:
needs: build-cargo-release
runs-on: ubuntu-latest
if: ${{ inputs.release_npm }}
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
id-token: write
contents: write
packages: write
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag }}
submodules: recursive
- name: Download cargo-release
uses: actions/download-artifact@v4
with:
name: cargo-release-bin
path: ./shared-bin
- name: Make binary executable and on PATH
run: |
chmod +x ./shared-bin/cargo-release
echo "$PWD/shared-bin" >> "$GITHUB_PATH"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
run: npm install -g pnpm
- name: Run NPM release (dry-run)
if: ${{ inputs.dry_run }}
run: cargo-release release npm ${{ github.event.inputs.release_tag }} --dry-run
- name: Run NPM release
if: ${{ !inputs.dry_run }}
run: cargo-release release npm ${{ github.event.inputs.release_tag }}
release-docker:
needs: build-cargo-release
runs-on: spacetimedb-new-runner-2
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.release_docker }}
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_tag }}
submodules: recursive
- name: Download cargo-release
uses: actions/download-artifact@v4
with:
name: cargo-release-bin
path: ./shared-bin
- name: Make binary executable and on PATH
run: |
chmod +x ./shared-bin/cargo-release
echo "$PWD/shared-bin" >> "$GITHUB_PATH"
# We need network=host during dry-runs but it's fine during non dry-runs as well
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{ !inputs.dry_run }}
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
# Docker Hub access tokens are passed to docker/login-action via the password input.
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run Docker release
run: cargo-release release docker ${{ github.event.inputs.release_tag }} ${{ inputs.dry_run && '--dry-run' || '' }}
update-mirror-latest-version:
runs-on: ubuntu-latest
if: ${{ !inputs.dry_run && inputs.update_mirror_latest_version }}
steps:
- name: Verify mirror tag prefix exists
env:
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: |
set -uo pipefail
PREFIX="refs/tags/$RELEASE_TAG/"
COUNT="$(aws s3api list-objects-v2 \
--bucket spacetimedb-client-binaries \
--prefix "$PREFIX" \
--max-keys 1 \
--query 'length(not_null(Contents, `[]`))')"
test "$COUNT" -gt 0
- name: Generate latest-version marker
env:
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
run: printf '%s\n' "$RELEASE_TAG" > latest-version
- name: Upload latest-version to S3 mirror
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: aws s3 cp latest-version s3://spacetimedb-client-binaries/latest-version --acl public-read