@@ -5,7 +5,10 @@ name: Release
55# Scripts/version.sh patch && git push --follow-tags
66# Running the workflow by hand (Actions › Release › Run workflow) builds and signs without releasing.
77#
8- # Secrets (README › Releasing):
8+ # The job runs in the "release" environment, which holds the secrets and waits for its approver:
9+ # a branch's own copy of this file can't read them, and nothing is signed without that approval.
10+ #
11+ # Secrets, in the release environment (README › Releasing):
912# OATCAKE_SIGNING_P12, OATCAKE_SIGNING_P12_PASSWORD the "Oatcake Release" code-signing identity
1013# OATCAKE_UPDATE_KEY the Ed25519 key that signs latest.json
1114on :
@@ -19,6 +22,9 @@ permissions:
1922jobs :
2023 release :
2124 runs-on : macos-26
25+ # A release takes about seven minutes. Anything much longer is stuck.
26+ timeout-minutes : 30
27+ environment : release
2228 permissions :
2329 contents : write # to create the release
2430 steps :
3642 exit 1
3743 fi
3844
45+ # Tested and built before the signing identity is on the runner: nothing that runs while the
46+ # package and its dependency are built or tested can sign with it. Packaging then only copies
47+ # what was built (OATCAKE_BIN), without running swift again.
48+ - run : swift test
49+
50+ - name : Build
51+ run : |
52+ swift build -c release --product Oatcake
53+ swift build -c release --product OatcakeRecorder
54+ echo "OATCAKE_BIN=$(swift build -c release --show-bin-path)" >> "$GITHUB_ENV"
55+
3956 # A throwaway keychain holding only the release identity. It's self-signed and so not trusted,
4057 # which codesign accepts; what matters is that every release carries the same one.
4158 - name : Import the signing certificate
@@ -59,14 +76,12 @@ jobs:
5976 # codesign on the runner only finds identities in keychains on the search list.
6077 security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
6178 security find-identity -p codesigning "$keychain"
62- # Fail here rather than after the build if the identity can't sign.
79+ # Fail here rather than part-way through packaging if the identity can't sign.
6380 cp /usr/bin/true "$RUNNER_TEMP/sign-test"
6481 codesign --force --sign "Oatcake Release" --keychain "$keychain" "$RUNNER_TEMP/sign-test"
6582 echo "OATCAKE_SIGN_KEYCHAIN=$keychain" >> "$GITHUB_ENV"
6683
67- - run : swift test
68-
69- # Builds the app and the recorder, bundles them with llama.cpp's server (a fixed build, checked
84+ # Bundles the app and the recorder (built above) with llama.cpp's server (a fixed build, checked
7085 # against its SHA-256) and signs the lot (Scripts/bundle.sh).
7186 - name : Package
7287 env :
@@ -88,7 +103,36 @@ jobs:
88103 *"certificate leaf"*) ;;
89104 *) echo "::error::$bundle isn't signed with the release certificate."; exit 1 ;;
90105 esac
106+ # And for the hardened runtime, so nothing else on a Mac can load its code into it.
107+ case "$(codesign -d -v "$bundle" 2>&1)" in
108+ *"(runtime)"*) ;;
109+ *) echo "::error::$bundle isn't signed for the hardened runtime."; exit 1 ;;
110+ esac
111+ done
112+ # The app's requirement names the versions it stands for, so the permissions macOS gives
113+ # it aren't also an earlier release's (Scripts/bundle.sh).
114+ for bundle in "$app" "$app/Contents/Resources/OatcakeRecorder.app"; do
115+ case "$(codesign -d -r - "$bundle" 2>/dev/null)" in
116+ *CFBundleShortVersionString*) ;;
117+ *) echo "::error::$bundle's designated requirement doesn't name a version."; exit 1 ;;
118+ esac
91119 done
120+ # Without this on Oatcake itself, macOS never asks for the microphone and nothing can be recorded.
121+ for bundle in "$app" "$app/Contents/Resources/OatcakeRecorder.app"; do
122+ case "$(codesign -d --entitlements - "$bundle" 2>/dev/null)" in
123+ *com.apple.security.device.audio-input*) ;;
124+ *) echo "::error::$bundle isn't signed as using the microphone."; exit 1 ;;
125+ esac
126+ done
127+
128+ # install.sh names the certificate it accepts. It has to be the one this was signed with, or
129+ # the installer published with this release would turn the release away.
130+ - name : Check install.sh accepts this build
131+ run : |
132+ certificate="$(sed -n "s/^ *CERTIFICATE='\(.*\)'$/\1/p" install.sh)"
133+ test -n "$certificate"
134+ codesign --verify --deep --strict -R "=identifier \"local.oatcake\" and $certificate" build/Oatcake.app
135+ codesign --verify --deep --strict -R "=identifier \"local.oatcake.recorder\" and $certificate" build/Oatcake.app/Contents/Resources/OatcakeRecorder.app
92136
93137 # ditto keeps the code signatures intact.
94138 - name : Zip
@@ -110,7 +154,8 @@ jobs:
110154 --zip "$ZIP" \
111155 --url "https://github.com/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/$ZIP" \
112156 --notes "$RUNNER_TEMP/notes.txt" > latest.json
113- cat latest.json
157+ # What was signed, without the signature: a run by hand signs a build that isn't released.
158+ plutil -extract payload raw -o - latest.json | base64 --decode
114159
115160 - name : Release
116161 if : github.ref_type == 'tag'
@@ -120,18 +165,20 @@ jobs:
120165 For Apple Silicon Macs on macOS 15 or later. To install, paste this into Terminal:
121166
122167 ```
123- curl -fsSL https://raw.githubusercontent. com/a8cteam51/oatcake/trunk /install.sh | sh
168+ curl -fsSL https://github. com/a8cteam51/oatcake/releases/latest/download /install.sh | sh
124169 ```
125170
126171 Or download the zip below, move Oatcake to your Applications folder and open it. Oatcake isn't notarised, so macOS blocks a copy downloaded with a browser until you click Open Anyway in System Settings › Privacy & Security; the install line avoids that.
127172
128173 Installed copies update themselves (Settings › Updates). The first recording asks for microphone and system-audio permission for "OatcakeRecorder".
129- # --notes goes above the generated list of changes.
130- run : gh release create "$GITHUB_REF_NAME" "$ZIP" latest.json --repo "$GITHUB_REPOSITORY" --title "Oatcake $GITHUB_REF_NAME" --generate-notes --notes "$NOTES"
174+ # --notes goes above the generated list of changes. install.sh goes out with the release, so
175+ # the install line runs the installer that was approved with it, not whatever trunk holds.
176+ run : gh release create "$GITHUB_REF_NAME" "$ZIP" latest.json install.sh --repo "$GITHUB_REPOSITORY" --title "Oatcake $GITHUB_REF_NAME" --generate-notes --notes "$NOTES"
131177
132178 # What install.sh and installed copies will fetch.
133179 - name : Check the feed serves this release
134180 if : github.ref_type == 'tag'
135181 run : |
136182 sleep 5
137183 curl -fsSL "https://github.com/$GITHUB_REPOSITORY/releases/latest/download/latest.json" | cmp - latest.json
184+ curl -fsSL "https://github.com/$GITHUB_REPOSITORY/releases/latest/download/install.sh" | cmp - install.sh
0 commit comments