Repository navigation
385 lines (377 loc) · 18.2 KB
/
Copy pathdistribution.yml
File metadata and controls
385 lines (377 loc) · 18.2 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
name: Distribution
run-name: Distribute build ${{ inputs.build_run_id || github.event.workflow_run.id }}
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
build_run_id:
description: Original main-push CI run ID (never a distribution run ID)
required: true
type: string
permissions:
contents: read
actions: read
# Share the original CI run's lock, including legacy CI signing retries.
# Never interrupt an active Apple upload with a newer recovery execution.
concurrency:
group: ci-${{ inputs.build_run_id || github.event.workflow_run.id }}
cancel-in-progress: false
jobs:
source:
name: Verify original build provenance
if: >-
github.ref == 'refs/heads/main' &&
((github.event_name == 'workflow_dispatch') ||
(github.event_name == 'workflow_run' && github.event.action == 'completed' &&
github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.path == '.github/workflows/ci.yml' &&
github.event.workflow_run.repository.full_name == github.repository &&
github.event.workflow_run.head_repository.full_name == github.repository))
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
run_id: ${{ steps.source.outputs.run_id }}
run_number: ${{ steps.source.outputs.run_number }}
run_attempt: ${{ steps.source.outputs.run_attempt }}
sha: ${{ steps.source.outputs.sha }}
artifact_id: ${{ steps.source.outputs.artifact_id }}
artifact_digest: ${{ steps.source.outputs.artifact_digest }}
version: ${{ steps.source.outputs.version }}
tag: ${{ steps.source.outputs.tag }}
automation_sha: ${{ steps.source.outputs.automation_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- name: Build trusted artifact verifier
run: go build -p 2 -trimpath -o "$RUNNER_TEMP/queue-notary-tool" ./cmd/queue-tool
- name: Select and verify immutable original app
id: source
env:
GH_TOKEN: ${{ github.token }}
INPUT_BUILD_RUN_ID: ${{ inputs.build_run_id }}
QUEUE_NOTARY_TOOL: ${{ runner.temp }}/queue-notary-tool
run: scripts/distribution-source.sh select verified-source
notarize:
name: Sign and notarize main installer
needs: [source]
runs-on: macos-15
timeout-minutes: 45
permissions:
contents: read
actions: read
environment: apple-signing
env:
BUILD_RUN_ID: ${{ needs.source.outputs.run_id }}
BUILD_RUN_NUMBER: ${{ needs.source.outputs.run_number }}
BUILD_RUN_ATTEMPT: ${{ needs.source.outputs.run_attempt }}
BUILD_SHA: ${{ needs.source.outputs.sha }}
BUILD_ARTIFACT_ID: ${{ needs.source.outputs.artifact_id }}
BUILD_ARTIFACT_DIGEST: ${{ needs.source.outputs.artifact_digest }}
BUILD_VERSION: ${{ needs.source.outputs.version }}
BUILD_TAG: ${{ needs.source.outputs.tag }}
AUTOMATION_SHA: ${{ needs.source.outputs.automation_sha }}
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
EXPECTED_XCODE_VERSION: '16.4'
EXPECTED_XCODE_BUILD: 16F6
APPLE_SIGNING_IDENTITY: ${{ vars.APPLE_SIGNING_IDENTITY }}
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
APPLE_NOTARY_KEY_ID: ${{ vars.APPLE_NOTARY_KEY_ID }}
APPLE_NOTARY_ISSUER_ID: ${{ vars.APPLE_NOTARY_ISSUER_ID }}
NOTARY_TIMEOUT: ${{ vars.APPLE_NOTARY_TIMEOUT || '5m' }}
outputs:
team_id: ${{ steps.apple-team.outputs.team_id }}
artifact_name: ${{ steps.final-artifact-name.outputs.name }}
steps:
- name: Record the expected public Apple team identifier
id: apple-team
env:
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
run: |
[[ "$APPLE_TEAM_ID" =~ ^[A-Z0-9]{10}$ ]]
printf 'team_id=%s\n' "$APPLE_TEAM_ID" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ needs.source.outputs.automation_sha }}
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- name: Build the notarization client before credential setup
env:
QUEUE_NOTARY_TOOL: ${{ runner.temp }}/queue-notary-tool
run: |
go build -p 2 -trimpath -o "$QUEUE_NOTARY_TOOL" ./cmd/queue-tool
printf 'QUEUE_NOTARY_TOOL=%s\n' "$QUEUE_NOTARY_TOOL" >> "$GITHUB_ENV"
- name: Qualify and record selected Apple tools before credentials
run: |
scripts/apple-toolchain.sh "$RUNNER_TEMP/apple-toolchain.json"
printf 'APPLE_TOOLCHAIN_RECEIPT=%s/apple-toolchain.json\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
- name: Verify original artifact provenance and bytes before recovery
env:
GH_TOKEN: ${{ github.token }}
run: scripts/distribution-source.sh download validated-app
- name: Restore the latest checkpoint for this exact main build
id: restore
env:
GH_TOKEN: ${{ github.token }}
run: scripts/macos-checkpoint.sh restore notarization-state
- name: Verify and extract the validated app
if: steps.restore.outputs.restored == 'false'
run: |
(cd validated-app && shasum -a 256 -c ./*.zip.sha256)
mkdir -p prepared-app
ditto -x -k "validated-app/Agent-Queue-$BUILD_VERSION-universal.zip" prepared-app
"$QUEUE_NOTARY_TOOL" verify-app --app 'prepared-app/Agent Queue.app'
- name: Initialize durable signing state
if: steps.restore.outputs.restored == 'false'
run: scripts/macos-resume.sh init 'prepared-app/Agent Queue.app' notarization-state "$BUILD_VERSION"
- name: Bind retained initial app to the exact original source bytes
run: |
scripts/macos-resume.sh bind-origin notarization-state \
"validated-app/Agent-Queue-$BUILD_VERSION-universal.zip" "$BUILD_VERSION"
- name: Verify restored build identity and signed archives
run: scripts/macos-resume.sh verify-state notarization-state "$BUILD_VERSION"
- name: Snapshot state before credential setup
run: scripts/macos-checkpoint.sh snapshot notarization-state "$RUNNER_TEMP/checkpoint-initial"
- name: Retain initial recovery state before signing
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: Apple-notarization-b${{ needs.source.outputs.run_id }}-r${{ github.run_id }}-a${{ github.run_attempt }}-s00
path: ${{ runner.temp }}/checkpoint-initial/*
if-no-files-found: error
retention-days: 90
- name: Notarize the app
uses: ./.github/actions/notarization-stage
with:
stage: app
prepared-slot: '01'
submitted-slot: '02'
finished-slot: '03'
certificate: ${{ secrets.APPLE_DEVELOPER_ID_P12_BASE64 }}
certificate-password: ${{ secrets.APPLE_DEVELOPER_ID_P12_PASSWORD }}
notary-key: ${{ secrets.APPLE_NOTARY_KEY_P8 }}
- name: Notarize the distribution disk image
uses: ./.github/actions/notarization-stage
with:
stage: dmg
prepared-slot: '07'
submitted-slot: '08'
finished-slot: '09'
certificate: ${{ secrets.APPLE_DEVELOPER_ID_P12_BASE64 }}
certificate-password: ${{ secrets.APPLE_DEVELOPER_ID_P12_PASSWORD }}
notary-key: ${{ secrets.APPLE_NOTARY_KEY_P8 }}
- name: Retain immutable publication evidence for this candidate
run: scripts/macos-resume.sh evidence notarization-state "$BUILD_VERSION"
- name: Export only completed notarized assets
id: export
run: scripts/macos-resume.sh export notarization-state dist "$BUILD_VERSION"
- name: Snapshot final candidate after export verification
id: export-snapshot
if: always() && steps.export.outcome != 'skipped'
run: scripts/macos-checkpoint.sh snapshot notarization-state "$RUNNER_TEMP/checkpoint-export"
- name: Persist final candidate after export verification
id: export-upload
if: always() && steps.export-snapshot.outcome == 'success'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: Apple-notarization-b${{ needs.source.outputs.run_id }}-r${{ github.run_id }}-a${{ github.run_attempt }}-s10
path: ${{ runner.temp }}/checkpoint-export/*
if-no-files-found: error
retention-days: 90
- name: Select final candidate receipts and export continuation
if: always() && steps.export-upload.outcome == 'success'
env:
CHECKPOINT_ID: ${{ steps.export-upload.outputs.artifact-id }}
CHECKPOINT_DIGEST: ${{ steps.export-upload.outputs.artifact-digest }}
APPLE_SIGNING_RESULT_FILE: ${{ runner.temp }}/apple-finish-dmg.json
run: scripts/macos-receipts.sh notarization-state "$RUNNER_TEMP/receipts-export" dmg "$CHECKPOINT_ID" "$CHECKPOINT_DIGEST"
- name: Retain final candidate public receipts and diagnostics
if: always() && steps.export-upload.outcome == 'success'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: Apple-receipts-b${{ needs.source.outputs.run_id }}-r${{ github.run_id }}-a${{ github.run_attempt }}-s10
path: ${{ runner.temp }}/receipts-export/*
if-no-files-found: error
retention-days: 90
- name: Generate final immutable manifest and Homebrew cask
run: |
"$QUEUE_NOTARY_TOOL" render-cask \
--archive "dist/Agent-Queue-$BUILD_VERSION-universal.zip" \
--version "$BUILD_VERSION" --tag "$BUILD_TAG" \
--commit "$BUILD_SHA" --build "$BUILD_RUN_NUMBER" --output dist
- name: Bind permanent public Apple evidence to the exact final assets
run: cp notarization-state/publication.json dist/apple-notarization.json
- name: Upload notarized app and final checksums
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: Agent-Queue-Notarized-App-${{ github.run_attempt }}
path: dist/*
if-no-files-found: error
retention-days: 90
- name: Record final artifact identity
id: final-artifact-name
run: printf 'name=Agent-Queue-Notarized-App-%s\n' "$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
- name: Explain retained state and safe recovery
if: always()
run: |
{
printf '### Apple notarization attempt %s\n\n' "$GITHUB_RUN_ATTEMPT"
printf 'Checkpoints retain exact signed archives for 90 days; small public receipts are retained independently for 90 days and published with successful releases.\n\n'
printf 'The automatic observer resumes classified pending/ticket failures with the same run, candidate and UUID. Its bounded retry budget is separate from Apple acceptance.\n\n'
printf 'Use workflow_dispatch on main with build_run_id=%s to apply current automation to these original bytes.\n\n' "$BUILD_RUN_ID"
printf 'CLI command: gh run rerun %s --failed --repo %s\n\n' "$GITHUB_RUN_ID" "$GITHUB_REPOSITORY"
printf 'No pending or rejected artifact is published. Missing state or an uncertain upload stops recovery for manual reconciliation.\n'
} >> "$GITHUB_STEP_SUMMARY"
notarized-tests:
name: Notarized distribution (${{ matrix.os }})
needs: [source, notarize]
strategy:
fail-fast: false
matrix:
os: [macos-15, macos-15-intel]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
env:
BUILD_RUN_ID: ${{ needs.source.outputs.run_id }}
BUILD_RUN_NUMBER: ${{ needs.source.outputs.run_number }}
BUILD_RUN_ATTEMPT: ${{ needs.source.outputs.run_attempt }}
BUILD_SHA: ${{ needs.source.outputs.sha }}
BUILD_ARTIFACT_ID: ${{ needs.source.outputs.artifact_id }}
BUILD_ARTIFACT_DIGEST: ${{ needs.source.outputs.artifact_digest }}
BUILD_VERSION: ${{ needs.source.outputs.version }}
BUILD_TAG: ${{ needs.source.outputs.tag }}
AUTOMATION_SHA: ${{ needs.source.outputs.automation_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ needs.source.outputs.automation_sha }}
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.notarize.outputs.artifact_name }}
path: dist
- name: Verify final checksums, signatures, tickets and production app copy
env:
APPLE_TEAM_ID: ${{ needs.notarize.outputs.team_id }}
run: |
(cd dist && shasum -a 256 -c ./*.sha256)
scripts/test-notarized-installer.sh "dist/Agent-Queue-$BUILD_VERSION-universal.zip" "dist/Agent-Queue-$BUILD_VERSION-universal.dmg" "$APPLE_TEAM_ID"
- name: Exercise the hardened packaged queue and HTTPS gateway
run: scripts/test-installer.sh "dist/Agent-Queue-$BUILD_VERSION-universal.zip"
- name: Install through the real Homebrew DSL with quarantine retained
env:
APPLE_TEAM_ID: ${{ needs.notarize.outputs.team_id }}
HOMEBREW_NO_AUTO_UPDATE: '1'
HOMEBREW_DEVELOPER: '1'
run: |
mkdir prepared-signed-app
ditto -x -k "dist/Agent-Queue-$BUILD_VERSION-universal.zip" prepared-signed-app
export AGENT_QUEUE_TEST_NOTARIZED_APP="$PWD/prepared-signed-app/Agent Queue.app"
go test -p 2 -parallel 2 ./internal/tooling -run '^TestNotarizedHomebrew' -count=1 -v -timeout 3m
publish:
name: Publish main installer
needs: [source, notarize, notarized-tests]
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
env:
BUILD_RUN_ID: ${{ needs.source.outputs.run_id }}
BUILD_RUN_NUMBER: ${{ needs.source.outputs.run_number }}
BUILD_RUN_ATTEMPT: ${{ needs.source.outputs.run_attempt }}
BUILD_SHA: ${{ needs.source.outputs.sha }}
BUILD_ARTIFACT_ID: ${{ needs.source.outputs.artifact_id }}
BUILD_ARTIFACT_DIGEST: ${{ needs.source.outputs.artifact_digest }}
BUILD_VERSION: ${{ needs.source.outputs.version }}
BUILD_TAG: ${{ needs.source.outputs.tag }}
AUTOMATION_SHA: ${{ needs.source.outputs.automation_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ needs.source.outputs.automation_sha }}
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.notarize.outputs.artifact_name }}
path: dist
- name: Build the stage record validator from this automation commit
run: go build -p 2 -trimpath -o "$RUNNER_TEMP/queue-notary-tool" ./cmd/queue-tool
- name: Publish immutable main build
env:
GH_TOKEN: ${{ github.token }}
QUEUE_NOTARY_TOOL: ${{ runner.temp }}/queue-notary-tool
run: scripts/distribution-publish.sh dist
homebrew-sync:
name: Verify Homebrew delivery
needs: [source, publish, notarize]
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
env:
BUILD_RUN_ID: ${{ needs.source.outputs.run_id }}
BUILD_RUN_NUMBER: ${{ needs.source.outputs.run_number }}
BUILD_RUN_ATTEMPT: ${{ needs.source.outputs.run_attempt }}
BUILD_SHA: ${{ needs.source.outputs.sha }}
BUILD_ARTIFACT_ID: ${{ needs.source.outputs.artifact_id }}
BUILD_ARTIFACT_DIGEST: ${{ needs.source.outputs.artifact_digest }}
BUILD_VERSION: ${{ needs.source.outputs.version }}
BUILD_TAG: ${{ needs.source.outputs.tag }}
AUTOMATION_SHA: ${{ needs.source.outputs.automation_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ needs.source.outputs.automation_sha }}
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.notarize.outputs.artifact_name }}
path: dist
- name: Require Homebrew dispatch configuration
env:
APP_CLIENT_ID: ${{ vars.HOMEBREW_SYNC_APP_CLIENT_ID }}
APP_PRIVATE_KEY: ${{ secrets.HOMEBREW_SYNC_APP_PRIVATE_KEY }}
run: |
if [[ -z "$APP_CLIENT_ID" || -z "$APP_PRIVATE_KEY" ]]; then
echo '::error::Configure HOMEBREW_SYNC_APP_CLIENT_ID and HOMEBREW_SYNC_APP_PRIVATE_KEY before Homebrew delivery. See docs/homebrew-delivery.md.'
exit 1
fi
- name: Create token for the tap workflow only
id: tap-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.HOMEBREW_SYNC_APP_CLIENT_ID }}
private-key: ${{ secrets.HOMEBREW_SYNC_APP_PRIVATE_KEY }}
owner: Dunky13
repositories: homebrew-agent-job-queue
permission-actions: write
- name: Dispatch and verify the published Homebrew build
shell: bash
env:
GH_TOKEN: ${{ steps.tap-token.outputs.token }}
SOURCE_GH_TOKEN: ${{ github.token }}
run: |
go run -p 2 ./cmd/queue-delivery --manifest dist/agent-job-queue.json \
--timeout 600 --poll-interval 5 | tee -a "$GITHUB_STEP_SUMMARY"