Repository navigation
383 lines (358 loc) · 15.9 KB
/
Copy pathrelease.yml
File metadata and controls
383 lines (358 loc) · 15.9 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
name: "Release"
on:
workflow_dispatch:
inputs:
windows:
description: "Build and publish the Windows installer with this release. Off: a Mac-only release, as before Windows joined."
type: boolean
default: true
channel:
description: "stable: the release the update feed and Latest point at. test: a prerelease on the updater-test feed, for trying the updater on a Mac and a PC."
type: choice
options:
- stable
- test
default: stable
# Two releases must never write the feeds at the same time.
concurrency:
group: release
cancel-in-progress: false
jobs:
validate-release-source:
if: >-
github.ref == 'refs/heads/main' &&
github.actor == github.repository_owner &&
github.triggering_actor == github.repository_owner
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.source.outputs.sha }}
steps:
- name: Checkout selected commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Validate immutable main source
id: source
shell: bash
run: |
set -euo pipefail
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
test "$GITHUB_SHA" = "$(git rev-parse refs/remotes/origin/main)"
echo "sha=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
# A stable release is x.y.z, a test release x.y.z-test.N: a test version
# can never become Latest, and a stable version never lands on the test feed.
- name: Check the version suits the channel
shell: bash
env:
CHANNEL: ${{ inputs.channel }}
run: |
set -euo pipefail
version=$(jq -r .version src-tauri/tauri.conf.json)
case "$CHANNEL" in
stable) pattern='^[0-9]+\.[0-9]+\.[0-9]+$' ;;
test) pattern='^[0-9]+\.[0-9]+\.[0-9]+-test\.[0-9]+$' ;;
*) echo "::error::Unknown channel $CHANNEL"; exit 1 ;;
esac
if ! [[ "$version" =~ $pattern ]]; then
echo "::error::Version $version does not suit the $CHANNEL channel (stable: x.y.z, test: x.y.z-test.N)"
exit 1
fi
create-release:
needs: validate-release-source
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
release-id: ${{ steps.create-release.outputs.result }}
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.validate-release-source.outputs.sha }}
persist-credentials: false
- name: Get version from tauri.conf.json
id: get-version
shell: bash
run: |
VERSION=$(grep -o '"version": "[^"]*"' src-tauri/tauri.conf.json | cut -d'"' -f4)
echo "Application version from tauri.conf.json: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create Draft Release
id: create-release
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${{ steps.get-version.outputs.version }}`,
target_commitish: '${{ needs.validate-release-source.outputs.sha }}',
name: `v${{ steps.get-version.outputs.version }}`,
draft: true,
prerelease: false,
generate_release_notes: true
})
return data.id
publish-tauri:
permissions:
contents: write
needs: [validate-release-source, create-release]
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-26" # for Arm based Macs (M1 and above).
args: "--target aarch64-apple-darwin"
target: "aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
target: "x86_64-apple-darwin"
uses: ./.github/workflows/build.yml
with:
platform: ${{ matrix.platform }}
target: ${{ matrix.target }}
build-args: ${{ matrix.args }}${{ inputs.channel == 'test' && ' --config src-tauri/updater-test.conf.json' || '' }}
sign-binaries: true
asset-prefix: "murmur"
release-id: ${{ needs.create-release.outputs.release-id }}
ref: ${{ needs.validate-release-source.outputs.sha }}
environment: "release-signing"
# Releases always build from scratch — never restore the Rust cache, so a
# stale cached native lib can never be linked into a shipped artifact.
no-cache: true
secrets:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
MACOS_CERT_P12_BASE64: ${{ secrets.MACOS_CERT_P12_BASE64 }}
MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
# Windows is a beta but ships in the same release. The installer and its
# signature reach the draft only after the install smoke test passed on it.
publish-windows:
if: ${{ inputs.windows }}
permissions:
contents: write
needs: [validate-release-source, create-release]
uses: ./.github/workflows/build-windows.yml
with:
release-id: ${{ needs.create-release.outputs.release-id }}
tag: v${{ needs.create-release.outputs.version }}
version: ${{ needs.create-release.outputs.version }}
ref: ${{ needs.validate-release-source.outputs.sha }}
updater-endpoint: ${{ inputs.channel == 'test' && format('https://github.com/{0}/releases/download/updater-test/latest.json', github.repository) || '' }}
secrets:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
# Runs when the Mac builds passed and the Windows build passed or was not
# asked for. A failed Windows build with windows=true leaves the draft
# unpublished, so no feed is ever half written.
publish-release:
if: ${{ always() && needs.publish-tauri.result == 'success' && ((inputs.windows && needs.publish-windows.result == 'success') || (!inputs.windows && needs.publish-windows.result == 'skipped')) }}
permissions:
contents: write
needs:
[validate-release-source, create-release, publish-tauri, publish-windows]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.validate-release-source.outputs.sha }}
persist-credentials: false
- name: Check the channel suits the version
env:
CHANNEL: ${{ inputs.channel }}
VERSION: ${{ needs.create-release.outputs.version }}
shell: bash
run: |
set -euo pipefail
case "$CHANNEL" in
stable) pattern='^[0-9]+\.[0-9]+\.[0-9]+$' ;;
test) pattern='^[0-9]+\.[0-9]+\.[0-9]+-test\.[0-9]+$' ;;
*) echo "::error::Unknown channel $CHANNEL"; exit 1 ;;
esac
if ! [[ "$VERSION" =~ $pattern ]]; then
echo "::error::Version $VERSION does not suit the $CHANNEL channel"
exit 1
fi
- name: Build and upload updater manifest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release-id }}
VERSION: ${{ needs.create-release.outputs.version }}
INCLUDE_WINDOWS: ${{ inputs.windows }}
run: node .github/scripts/publish-updater-manifest.mjs
# The manifest sits on the draft only. Every signature in it is checked
# against the file it points at and the updater public key before the
# release goes public.
- name: Download the assets the manifest points at
env:
RELEASE_ID: ${{ needs.create-release.outputs.release-id }}
shell: bash
run: |
set -euo pipefail
mkdir assets
gh api --paginate "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" \
--jq '.[] | [.id, .name] | @tsv' > asset-list.tsv
jq -r '.platforms[].url' latest.json | sort -u | while read -r url; do
name=$(node -e 'process.stdout.write(decodeURIComponent(process.argv[1].split("/").pop()))' "$url")
id=$(awk -F'\t' -v name="$name" '$2 == name { print $1 }' asset-list.tsv)
[ -n "$id" ] || { echo "::error::$name is not on the release"; exit 1; }
gh api -H "Accept: application/octet-stream" "repos/${GITHUB_REPOSITORY}/releases/assets/${id}" > "assets/${name}"
done
- name: Verify the updater signatures
env:
VERSION: ${{ needs.create-release.outputs.version }}
RELEASE_TAG: v${{ needs.create-release.outputs.version }}
INCLUDE_WINDOWS: ${{ inputs.windows }}
run: node .github/scripts/publish-updater-manifest.mjs --verify-signatures assets
# Read before anything is public: the feed the old Windows betas read
# must exist, and its current file is kept for a rollback.
- name: Keep the previous windows-beta feed and prepare the new one
if: inputs.channel == 'stable' && inputs.windows
env:
VERSION: ${{ needs.create-release.outputs.version }}
RELEASE_TAG: v${{ needs.create-release.outputs.version }}
shell: bash
run: |
set -euo pipefail
gh release view windows-beta > /dev/null
mkdir previous-feed legacy-feed
curl --fail --silent --show-error --location \
--output previous-feed/latest.json \
"https://github.com/${GITHUB_REPOSITORY}/releases/download/windows-beta/latest.json"
node .github/scripts/publish-updater-manifest.mjs --emit-legacy-feed legacy-feed/latest.json
- name: Keep the previous windows-beta feed as an artifact
if: inputs.channel == 'stable' && inputs.windows
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: windows-beta-feed-before-${{ needs.create-release.outputs.version }}
path: previous-feed/latest.json
if-no-files-found: error
retention-days: 90
- name: Publish release
if: inputs.channel == 'stable'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: Number('${{ needs.create-release.outputs.release-id }}'),
draft: false,
prerelease: false,
make_latest: 'true'
})
# A test release is a prerelease and never Latest: the stable feed
# (releases/latest/download/latest.json) is not touched. The draft is
# created like a stable one; it becomes a prerelease here, at publication.
- name: Publish test prerelease
if: inputs.channel == 'test'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
env:
RELEASE_ID: ${{ needs.create-release.outputs.release-id }}
with:
script: |
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: Number(process.env.RELEASE_ID),
draft: false,
prerelease: true,
make_latest: 'false'
})
- name: Verify public updater manifest
if: inputs.channel == 'stable'
env:
VERSION: ${{ needs.create-release.outputs.version }}
INCLUDE_WINDOWS: ${{ inputs.windows }}
shell: bash
run: |
set -euo pipefail
url="https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/latest.json"
for attempt in 1 2 3 4 5; do
if manifest="$(curl --fail --silent --show-error --location "$url")" &&
VERSION="$VERSION" MANIFEST="$manifest" node .github/scripts/publish-updater-manifest.mjs --verify-public; then
exit 0
fi
sleep 5
done
echo "Updater manifest did not become publicly available" >&2
exit 1
- name: Point the windows-beta feed at this release
if: inputs.channel == 'stable' && inputs.windows
shell: bash
run: gh release upload windows-beta legacy-feed/latest.json --clobber
- name: Verify public windows-beta feed
if: inputs.channel == 'stable' && inputs.windows
env:
VERSION: ${{ needs.create-release.outputs.version }}
shell: bash
run: |
set -euo pipefail
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/windows-beta/latest.json"
# The asset was replaced in place, and GitHub serves the copy it
# replaced for a while: 25 s was too short for 1.14.2, which then
# read as failed although the feed was right a minute later.
for attempt in $(seq 1 30); do
if manifest="$(curl --fail --silent --show-error --location "$url")" &&
VERSION="$VERSION" MANIFEST="$manifest" node .github/scripts/publish-updater-manifest.mjs --verify-public-legacy; then
exit 0
fi
sleep 10
done
echo "The windows-beta feed did not become publicly available" >&2
exit 1
- name: Point the test feed at this release
if: inputs.channel == 'test'
env:
SHA: ${{ needs.validate-release-source.outputs.sha }}
shell: bash
run: |
set -euo pipefail
if ! gh release view updater-test > /dev/null 2>&1; then
gh release create updater-test \
--target "$SHA" \
--prerelease \
--latest=false \
--title "Updater test feed" \
--notes "Test builds of Murmur read their update feed from this release. Do not download anything from here. The test installers are the releases named v<version>-test.N."
fi
gh release upload updater-test latest.json --clobber
- name: Verify public test feed
if: inputs.channel == 'test'
env:
VERSION: ${{ needs.create-release.outputs.version }}
RELEASE_TAG: v${{ needs.create-release.outputs.version }}
INCLUDE_WINDOWS: ${{ inputs.windows }}
shell: bash
run: |
set -euo pipefail
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/updater-test/latest.json"
# This asset is replaced in place too, so GitHub serves the copy
# it replaced for a while.
for attempt in $(seq 1 30); do
if manifest="$(curl --fail --silent --show-error --location "$url")" &&
VERSION="$VERSION" MANIFEST="$manifest" node .github/scripts/publish-updater-manifest.mjs --verify-public; then
exit 0
fi
sleep 10
done
echo "The test feed did not become publicly available" >&2
exit 1