-
Notifications
You must be signed in to change notification settings - Fork 4
311 lines (284 loc) · 12.5 KB
/
Copy pathrelease.yml
File metadata and controls
311 lines (284 loc) · 12.5 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
name: Release
# Tag-driven. `v1.3.0` ships to the stable channel; any tag with a prerelease
# suffix (`v1.3.0-beta.1`) ships to the beta channel and is marked a GitHub
# prerelease. See docs/release-setup.md for the one-time secret setup.
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: Existing tag to (re)publish
required: true
permissions:
contents: write
pages: write
id-token: write
# Two releases racing would clobber each other's appcast.
concurrency:
group: release
cancel-in-progress: false
env:
SPARKLE_VERSION: "2.9.4"
FEED_URL: https://predict-woo.github.io/simbi/appcast.xml
jobs:
build:
name: Build, notarize, publish
runs-on: macos-26
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.tag || github.ref }}
# CFBundleVersion is the commit count, so shallow clones lie.
fetch-depth: 0
- name: Derive version metadata
id: meta
run: |
set -euo pipefail
TAG="${{ inputs.tag || github.ref_name }}"
VERSION="${TAG#v}"
BUILD=$(git rev-list --count HEAD)
if [[ "$VERSION" == *-* ]]; then
CHANNEL=beta
PRERELEASE=true
else
CHANNEL=stable
PRERELEASE=false
fi
{
echo "tag=$TAG"
echo "version=$VERSION"
echo "build=$BUILD"
echo "channel=$CHANNEL"
echo "prerelease=$PRERELEASE"
echo "dmg=Simbi-$VERSION.dmg"
echo "notes=Simbi-$VERSION-notes.html"
} >> "$GITHUB_OUTPUT"
echo "Releasing $VERSION (build $BUILD) to the $CHANNEL channel"
# A build signed with the placeholder key can never be updated by
# Sparkle — fail before it reaches anyone.
- name: Verify update-signing key is configured
run: |
if grep -q 'REPLACE_WITH_generate_keys_OUTPUT' project.yml; then
echo "::error::SPARKLE_PUBLIC_ED_KEY is still a placeholder. See docs/release-setup.md"
exit 1
fi
- name: Install build tools
run: brew install xcodegen create-dmg
- name: Fetch Sparkle release tools
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/sparkle"
curl -fsSL \
"https://github.com/sparkle-project/Sparkle/releases/download/${SPARKLE_VERSION}/Sparkle-${SPARKLE_VERSION}.tar.xz" \
| tar -xJ -C "$RUNNER_TEMP/sparkle"
# Smoke-test the tool; sign_update has no --version flag.
"$RUNNER_TEMP/sparkle/bin/sign_update" --help > /dev/null
- name: Import Developer ID certificate
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.DEV_ID_CERT_P12 }}
p12-password: ${{ secrets.DEV_ID_CERT_PASSWORD }}
# The vendored anydoc helper (scripts/fetch-anydoc.sh, run as a
# pre-build phase) must be universal in releases; the runner's Rust
# toolchain only carries the host target by default.
- name: Add Rust x86_64 target
run: rustup target add x86_64-apple-darwin
- name: Generate Xcode project
run: xcodegen generate
- name: Build (Developer ID, hardened runtime)
run: |
set -euo pipefail
xcodebuild \
-project Simbi.xcodeproj \
-scheme Simbi \
-configuration Release \
-destination 'platform=macOS' \
-derivedDataPath build \
MARKETING_VERSION='${{ steps.meta.outputs.version }}' \
CURRENT_PROJECT_VERSION='${{ steps.meta.outputs.build }}' \
CODE_SIGN_STYLE=Manual \
CODE_SIGN_IDENTITY="Developer ID Application" \
DEVELOPMENT_TEAM='${{ secrets.APPLE_TEAM_ID }}' \
OTHER_CODE_SIGN_FLAGS="--timestamp" \
CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \
build
# The `build` action copies Sparkle.framework as shipped by the Sparkle
# project — its nested executables carry Sparkle's signature, which the
# notary service rejects. Re-sign inside-out with our Developer ID, then
# re-seal the app bundle the re-signing just invalidated.
- name: Re-sign Sparkle framework components
run: |
set -euo pipefail
APP=build/Build/Products/Release/Simbi.app
SPARKLE="$APP/Contents/Frameworks/Sparkle.framework"
SIGN=(codesign --force --sign "Developer ID Application" \
--options runtime --timestamp)
# Per Sparkle's docs only Downloader.xpc keeps its entitlements.
"${SIGN[@]}" "$SPARKLE/Versions/B/XPCServices/Installer.xpc"
"${SIGN[@]}" --preserve-metadata=entitlements \
"$SPARKLE/Versions/B/XPCServices/Downloader.xpc"
"${SIGN[@]}" "$SPARKLE/Versions/B/Autoupdate"
"${SIGN[@]}" "$SPARKLE/Versions/B/Updater.app"
"${SIGN[@]}" "$SPARKLE"
"${SIGN[@]}" --preserve-metadata=entitlements "$APP"
- name: Verify signature
run: |
set -euo pipefail
APP=build/Build/Products/Release/Simbi.app
codesign --verify --deep --strict --verbose=2 "$APP"
codesign -dv --verbose=4 "$APP" 2>&1 | grep -q 'flags=.*runtime' \
|| { echo "::error::hardened runtime missing"; exit 1; }
# notarytool rejects any build whose main executable still has the
# debugger entitlement.
if codesign -d --entitlements - --xml "$APP" 2>/dev/null \
| grep -q get-task-allow; then
echo "::error::get-task-allow entitlement present"; exit 1
fi
# Sparkle's XPC services and Autoupdate.app must carry our identity
# (not Sparkle's) or notarization and updates are rejected.
codesign --verify --strict \
"$APP/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate"
codesign -dv \
"$APP/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate" 2>&1 \
| grep -q 'TeamIdentifier=${{ secrets.APPLE_TEAM_ID }}' \
|| { echo "::error::Sparkle Autoupdate not signed with our team ID"; exit 1; }
# The bundled anydoc helper must be signed and universal, or
# notarization fails / Intel Macs silently lose the tool.
codesign --verify --strict "$APP/Contents/Helpers/anydoc"
lipo -archs "$APP/Contents/Helpers/anydoc" | grep -q x86_64 \
|| { echo "::error::anydoc helper is not universal"; exit 1; }
lipo -archs "$APP/Contents/Helpers/anydoc" | grep -q arm64 \
|| { echo "::error::anydoc helper is not universal"; exit 1; }
- name: Notarize the app
env:
AC_API_KEY_P8: ${{ secrets.AC_API_KEY_P8 }}
run: |
set -euo pipefail
APP=build/Build/Products/Release/Simbi.app
printf '%s' "$AC_API_KEY_P8" > "$RUNNER_TEMP/ac_key.p8"
ditto -c -k --keepParent "$APP" "$RUNNER_TEMP/Simbi.zip"
xcrun notarytool submit "$RUNNER_TEMP/Simbi.zip" \
--key "$RUNNER_TEMP/ac_key.p8" \
--key-id '${{ secrets.AC_API_KEY_ID }}' \
--issuer '${{ secrets.AC_API_ISSUER_ID }}' \
--wait
# Staple the app itself so the copy Sparkle installs validates
# offline, not just the disk image it arrived in.
xcrun stapler staple "$APP"
- name: Build and notarize the DMG
env:
DMG: ${{ steps.meta.outputs.dmg }}
run: |
set -euo pipefail
mkdir -p dist stage
cp -R build/Build/Products/Release/Simbi.app stage/
create-dmg \
--volname "Simbi" \
--window-size 540 380 \
--icon-size 96 \
--icon "Simbi.app" 140 190 \
--app-drop-link 400 190 \
--no-internet-enable \
"dist/$DMG" stage/
codesign --force --timestamp \
--sign "Developer ID Application" "dist/$DMG"
xcrun notarytool submit "dist/$DMG" \
--key "$RUNNER_TEMP/ac_key.p8" \
--key-id '${{ secrets.AC_API_KEY_ID }}' \
--issuer '${{ secrets.AC_API_ISSUER_ID }}' \
--wait
xcrun stapler staple "dist/$DMG"
xcrun stapler validate "dist/$DMG"
# The last line of defence: exactly what Gatekeeper will do on a user's
# Mac. Better to fail the release than to ship a blocked build.
- name: Gatekeeper assessment
run: |
set -euo pipefail
hdiutil attach "dist/${{ steps.meta.outputs.dmg }}" -mountpoint /Volumes/SimbiCheck -nobrowse -quiet
spctl -a -vvv -t install /Volumes/SimbiCheck/Simbi.app
hdiutil detach /Volumes/SimbiCheck -quiet
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
prerelease: ${{ steps.meta.outputs.prerelease }}
generate_release_notes: true
files: dist/${{ steps.meta.outputs.dmg }}
- name: Render release notes for the update sheet
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.meta.outputs.tag }}
NOTES: ${{ steps.meta.outputs.notes }}
run: |
set -euo pipefail
gh release view "$TAG" --json body -q .body > "$RUNNER_TEMP/body.md"
# GitHub renders the markdown for us — no pandoc, no pip install.
gh api --method POST /markdown \
-f mode=gfm -f context=${{ github.repository }} \
-f text="$(cat "$RUNNER_TEMP/body.md")" > "$RUNNER_TEMP/body.html"
{
echo '<!doctype html><meta charset="utf-8">'
echo '<style>'
echo ':root{color-scheme:light dark}'
echo 'body{font:13px -apple-system,system-ui,sans-serif;margin:12px;line-height:1.5}'
echo 'h1,h2,h3{font-size:1.05em;margin:1em 0 .4em}'
echo 'code,pre{font-family:ui-monospace,SFMono-Regular,monospace;font-size:.92em}'
echo 'pre{padding:8px;border-radius:6px;overflow-x:auto;background:color-mix(in srgb,currentColor 8%,transparent)}'
echo 'a{color:AccentColor}'
echo '</style>'
cat "$RUNNER_TEMP/body.html"
} > "dist/$NOTES"
gh release upload "$TAG" "dist/$NOTES" --clobber
- name: Sign the update and append it to the appcast
env:
SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }}
DMG: ${{ steps.meta.outputs.dmg }}
TAG: ${{ steps.meta.outputs.tag }}
NOTES: ${{ steps.meta.outputs.notes }}
run: |
set -euo pipefail
mkdir -p site
# Start from the live feed so past releases survive; a missing feed
# (first release) is fine, anything else is a real failure.
STATUS=$(curl -sSL -o site/appcast.xml -w '%{http_code}' "$FEED_URL" || echo 000)
if [ "$STATUS" = "404" ]; then
rm -f site/appcast.xml
echo "No published feed yet — starting a new one."
elif [ "$STATUS" != "200" ]; then
echo "::error::Fetching $FEED_URL returned $STATUS; refusing to truncate the feed"
exit 1
fi
printf '%s' "$SPARKLE_ED_PRIVATE_KEY" > "$RUNNER_TEMP/ed_key"
SIGNED=$("$RUNNER_TEMP/sparkle/bin/sign_update" "dist/$DMG" \
--ed-key-file "$RUNNER_TEMP/ed_key")
rm -f "$RUNNER_TEMP/ed_key"
# sign_update prints: sparkle:edSignature="…" length="…"
SIGNATURE=$(sed -n 's/.*sparkle:edSignature="\([^"]*\)".*/\1/p' <<<"$SIGNED")
LENGTH=$(sed -n 's/.*length="\([0-9]*\)".*/\1/p' <<<"$SIGNED")
test -n "$SIGNATURE" && test -n "$LENGTH"
BASE="https://github.com/${{ github.repository }}/releases/download/$TAG"
python3 scripts/appcast.py \
--appcast site/appcast.xml \
--version '${{ steps.meta.outputs.version }}' \
--build '${{ steps.meta.outputs.build }}' \
--channel '${{ steps.meta.outputs.channel }}' \
--url "$BASE/$DMG" \
--length "$LENGTH" \
--signature "$SIGNATURE" \
--release-notes-url "$BASE/$NOTES"
cp scripts/pages-index.html site/index.html
- uses: actions/upload-pages-artifact@v3
with:
path: site
deploy-feed:
name: Publish appcast
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- id: deploy
uses: actions/deploy-pages@v4