Repository navigation
273 lines (273 loc) · 13.8 KB
/
Copy pathrelease.yml
File metadata and controls
273 lines (273 loc) · 13.8 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
name: release
# Builds portable release binaries for every `v*` tag and attaches them to a DRAFT GitHub release.
# A maintainer reviews the draft and publishes it; nothing goes public automatically.
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
# static: no glibc requirement (the gnu build needs glibc >= 2.34), and Alpine / arm64 Linux get a binary
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
archive: tar.gz
linker: aarch64-linux-gnu-gcc
cross: true
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
# built on Apple silicon, smoke-tested under Rosetta 2
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
rosetta: true
# the C runtime linked in: no VCRUNTIME140.dll needed on a clean Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
rustflags: -C target-feature=+crt-static
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: cross linker
if: ${{ matrix.linker }}
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
- name: build (portable, no CPU pin)
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
RUSTFLAGS: ${{ matrix.rustflags }}
run: cargo build --release --locked -p probbit-cli --target ${{ matrix.target }}
- name: smoke test
if: ${{ !matrix.cross }}
shell: bash
run: |
BIN="target/${{ matrix.target }}/release/probbit"
[ "${{ runner.os }}" = "Windows" ] && BIN="$BIN.exe"
RUN=""; [ "${{ matrix.rosetta }}" = "true" ] && RUN="arch -x86_64"
$RUN "$BIN" version
$RUN "$BIN" demo --tasks 12 | $RUN "$BIN" decide --pretty | head -8
- name: package
shell: bash
run: |
set -euo pipefail
NAME="probbit-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/$NAME"
if [ "${{ runner.os }}" = "Windows" ]; then
cp "target/${{ matrix.target }}/release/probbit.exe" "dist/$NAME/"
else
cp "target/${{ matrix.target }}/release/probbit" "dist/$NAME/"
fi
cp README.md LICENSE CHANGELOG.md "dist/$NAME/"
cp -R examples python docs "dist/$NAME/" # JSON examples, the Python wrapper, the IR spec and docs/agents.md
cd dist
if [ "${{ matrix.archive }}" = "zip" ]; then
ASSET="$NAME.zip"; 7z a "$ASSET" "$NAME" > /dev/null
else
ASSET="$NAME.tar.gz"; tar czf "$ASSET" "$NAME"
fi
if command -v sha256sum > /dev/null; then sha256sum "$ASSET" > "$ASSET.sha256"; else shasum -a 256 "$ASSET" > "$ASSET.sha256"; fi
echo "ASSET=$ASSET" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.target }}
path: |
dist/${{ env.ASSET }}
dist/${{ env.ASSET }}.sha256
if-no-files-found: error
macos-app:
# probbit Monitor.app: the two macOS builds above joined into one universal probbit (lipo), wrapped by
# apps/macos/ProbbitMonitor/build.sh (the script ci.yml runs on every commit), launched once, zipped. The zip and its
# .sha256 go to the release job with the other archives.
# Signing: with the repository secrets APPLE_DEVELOPER_ID_P12 (the Developer ID Application certificate and key, a
# base64 .p12), APPLE_DEVELOPER_ID_P12_PASSWORD and APPLE_TEAM_ID, the app is signed with that Developer ID and the
# hardened runtime, from a keychain made for this job and deleted at its end; with APPLE_NOTARY_KEY_P8 (an App Store
# Connect API key, a base64 .p8), APPLE_NOTARY_KEY_ID and APPLE_NOTARY_ISSUER_ID as well, it is notarized and the ticket
# stapled. Without them it is signed ad-hoc, as before, and the job says so. The secrets are given only to the steps
# that use them.
needs: build
runs-on: macos-latest
outputs:
signature: ${{ steps.app.outputs.signature }}
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: aarch64-apple-darwin
path: darwin
- uses: actions/download-artifact@v8
with:
name: x86_64-apple-darwin
path: darwin
- name: one universal probbit
run: |
set -euo pipefail
cd darwin
for T in aarch64-apple-darwin x86_64-apple-darwin; do
shasum -a 256 -c "probbit-${GITHUB_REF_NAME}-$T.tar.gz.sha256"
tar xzf "probbit-${GITHUB_REF_NAME}-$T.tar.gz"
done
lipo -create "probbit-${GITHUB_REF_NAME}-aarch64-apple-darwin/probbit" "probbit-${GITHUB_REF_NAME}-x86_64-apple-darwin/probbit" -output probbit
lipo -archs probbit
./probbit version
- name: signing credentials
id: creds
env:
APPLE_DEVELOPER_ID_P12: ${{ secrets.APPLE_DEVELOPER_ID_P12 }}
APPLE_DEVELOPER_ID_P12_PASSWORD: ${{ secrets.APPLE_DEVELOPER_ID_P12_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_NOTARY_KEY_P8: ${{ secrets.APPLE_NOTARY_KEY_P8 }}
APPLE_NOTARY_KEY_ID: ${{ secrets.APPLE_NOTARY_KEY_ID }}
APPLE_NOTARY_ISSUER_ID: ${{ secrets.APPLE_NOTARY_ISSUER_ID }}
run: |
# names only: which secrets are set (never their values)
missing() { for n in "$@"; do [ -n "${!n:-}" ] || printf ' %s' "$n"; done; }
sign_missing=$(missing APPLE_DEVELOPER_ID_P12 APPLE_DEVELOPER_ID_P12_PASSWORD APPLE_TEAM_ID)
notary_missing=$(missing APPLE_NOTARY_KEY_P8 APPLE_NOTARY_KEY_ID APPLE_NOTARY_ISSUER_ID)
sign=false; notarize=false
[ -n "$sign_missing" ] || sign=true
[ "$sign" = false ] || [ -n "$notary_missing" ] || notarize=true
echo "sign=$sign" >> "$GITHUB_OUTPUT"
echo "notarize=$notarize" >> "$GITHUB_OUTPUT"
if [ "$sign" = false ]; then
echo "No Developer ID secrets (missing:$sign_missing): the app is signed ad-hoc and not notarized."
elif [ "$notarize" = false ]; then
echo "Developer ID signing; no notary secrets (missing:$notary_missing): the app is not notarized."
else
echo "Developer ID signing and notarization."
fi
- name: the Developer ID certificate, in a keychain of this job
if: steps.creds.outputs.sign == 'true'
env:
APPLE_DEVELOPER_ID_P12: ${{ secrets.APPLE_DEVELOPER_ID_P12 }}
APPLE_DEVELOPER_ID_P12_PASSWORD: ${{ secrets.APPLE_DEVELOPER_ID_P12_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
set -euo pipefail
KC="$RUNNER_TEMP/probbit-signing-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT.keychain-db"
KC_PASS=$(openssl rand -hex 24)
echo "::add-mask::$KC_PASS"
security create-keychain -p "$KC_PASS" "$KC"
security set-keychain-settings -lut 3600 "$KC"
security unlock-keychain -p "$KC_PASS" "$KC"
umask 077
printf '%s' "$APPLE_DEVELOPER_ID_P12" | base64 --decode > "$RUNNER_TEMP/developer-id.p12"
security import "$RUNNER_TEMP/developer-id.p12" -k "$KC" -f pkcs12 -P "$APPLE_DEVELOPER_ID_P12_PASSWORD" -T /usr/bin/codesign > /dev/null
rm -f "$RUNNER_TEMP/developer-id.p12"
# the intermediate that issues Developer ID certificates, in case the runner lacks it (public, pinned by hash)
curl -fsSL -o "$RUNNER_TEMP/DeveloperIDG2CA.cer" https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
echo "f16cd3c54c7f83cea4bf1a3e6a0819c8aaa8e4a1528fd144715f350643d2df3a $RUNNER_TEMP/DeveloperIDG2CA.cer" | shasum -a 256 -c > /dev/null
security import "$RUNNER_TEMP/DeveloperIDG2CA.cer" -k "$KC" > /dev/null 2>&1 || true
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KC_PASS" "$KC" > /dev/null
# codesign is given this keychain (build.sh --keychain); it is also put on the search list so that the
# certificate chain is found there
OLD=(); while IFS= read -r k; do k=${k#*\"}; OLD+=("${k%\"}"); done < <(security list-keychains -d user)
security list-keychains -d user -s "$KC" "${OLD[@]}"
# the identity by its SHA-1 (codesign checks the certificate when it signs)
ID=$(security find-identity -p codesigning "$KC" | awk -v t="($APPLE_TEAM_ID)\"" 'index($0, "\"Developer ID Application: ") && index($0, t) { print $2; exit }')
[ -n "$ID" ] || { echo "The certificate holds no Developer ID Application identity of APPLE_TEAM_ID."; exit 1; }
echo "SIGN_KEYCHAIN=$KC" >> "$GITHUB_ENV"
echo "SIGN_IDENTITY=$ID" >> "$GITHUB_ENV"
echo "Developer ID Application identity imported (SHA-1 ${ID:0:8}...)."
- name: the notary API key
if: steps.creds.outputs.notarize == 'true'
env:
APPLE_NOTARY_KEY_P8: ${{ secrets.APPLE_NOTARY_KEY_P8 }}
run: |
set -euo pipefail
umask 077
printf '%s' "$APPLE_NOTARY_KEY_P8" | base64 --decode > "$RUNNER_TEMP/notary-key.p8"
echo "NOTARY_KEY=$RUNNER_TEMP/notary-key.p8" >> "$GITHUB_ENV"
- name: build the app
id: app
env:
SIGN: ${{ steps.creds.outputs.sign }}
NOTARIZE: ${{ steps.creds.outputs.notarize }}
APPLE_NOTARY_KEY_ID: ${{ secrets.APPLE_NOTARY_KEY_ID }}
APPLE_NOTARY_ISSUER_ID: ${{ secrets.APPLE_NOTARY_ISSUER_ID }}
run: |
set -euo pipefail
set -- --binary darwin/probbit --asset-version "$GITHUB_REF_NAME" --out app-dist
signature=ad-hoc
if [ "$SIGN" = true ]; then
set -- "$@" --identity "$SIGN_IDENTITY" --keychain "$SIGN_KEYCHAIN"
signature=developer-id
fi
if [ "$NOTARIZE" = true ]; then
set -- "$@" --notarize-key "$NOTARY_KEY" --notarize-key-id "$APPLE_NOTARY_KEY_ID" --notarize-issuer "$APPLE_NOTARY_ISSUER_ID"
signature=notarized
fi
apps/macos/ProbbitMonitor/build.sh "$@"
echo "signature=$signature" >> "$GITHUB_OUTPUT"
- name: Gatekeeper accepts it
if: steps.creds.outputs.notarize == 'true'
run: |
set -euo pipefail
xcrun stapler validate "app-dist/probbit Monitor.app"
spctl --assess --type execute -v "app-dist/probbit Monitor.app" 2>&1 | tee spctl.txt
grep -q "source=Notarized Developer ID" spctl.txt
- name: launch it, quit it
run: apps/macos/ProbbitMonitor/smoke.sh "app-dist/probbit Monitor.app" --quit term -- --demo week
- uses: actions/upload-artifact@v7
with:
name: macos-app
path: |
app-dist/probbit-Monitor-${{ github.ref_name }}-macos.zip
app-dist/probbit-Monitor-${{ github.ref_name }}-macos.zip.sha256
if-no-files-found: error
- name: the notarization record (kept with the run, not attached to the release)
if: always() && steps.creds.outputs.notarize == 'true'
uses: actions/upload-artifact@v7
with:
name: notarization-record
path: app-dist/probbit-Monitor-${{ github.ref_name }}-macos.notarization*.json
if-no-files-found: warn
- name: delete the keychain and the keys
if: always()
run: |
KC="$RUNNER_TEMP/probbit-signing-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT.keychain-db"
if [ -f "$KC" ]; then security delete-keychain "$KC" && echo "keychain deleted"; fi
rm -f "$RUNNER_TEMP/developer-id.p12" "$RUNNER_TEMP/notary-key.p8" "$RUNNER_TEMP/DeveloperIDG2CA.cer"
release:
needs: [build, macos-app]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: create or update the draft release
env:
GH_TOKEN: ${{ github.token }}
APP_SIGNATURE: ${{ needs.macos-app.outputs.signature }}
run: |
set -euo pipefail
rm -f dist/*.notarization*.json # the notarization record stays with the workflow run
cp docs/probbit.1 dist/ # the manual page (`probbit man`), also inside every archive under docs/
ls -la dist
APP="probbit-Monitor-$GITHUB_REF_NAME-macos.zip is probbit Monitor, the monitor as a universal Mac app"
case "$APP_SIGNATURE" in
notarized) APP="$APP, signed with a Developer ID and notarized by Apple: it opens on double-click." ;;
developer-id) APP="$APP, signed with a Developer ID, not notarized: allow its first launch once (docs/monitor-app.md)." ;;
*) APP="$APP, signed ad-hoc, not notarized: allow its first launch once (docs/monitor-app.md)." ;;
esac
if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" dist/* --clobber
else
gh release create "$GITHUB_REF_NAME" dist/* --draft --verify-tag --title "probbit $GITHUB_REF_NAME" \
--notes "Portable builds (no CPU pin) for Linux x86_64 (glibc >= 2.34, or static musl), Linux arm64 (static musl), macOS (Apple silicon and Intel) and Windows x86_64 (static C runtime). Verify an archive with the .sha256 file beside it. $APP What changed: see CHANGELOG.md."
fi