Repository navigation
754 lines (740 loc) · 36.1 KB
/
Copy pathrelease.yml
File metadata and controls
754 lines (740 loc) · 36.1 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
name: release
run-name: ${{ inputs.ci-run && format('Launcher {0} for CI {1}', inputs.operation, inputs.ci-run) || (github.event_name == 'push' && format('Reserve launcher version for {0}', github.sha)) || format('Launcher {0}', inputs.operation) }}
# Alpha's launcher release (spec/release/index.md, `pnpm release` in apps/app). A main push reserves
# a version: the push run number plus 1000. Successful main CI cuts its versioned draft, builds the
# unsigned APK into private storage with a signing plan, and queues `operation: deliver` with the
# plan's digest. The protected `release` environment signs exactly that plan's APK with Alpha's one
# key, verifies it (`pnpm android verify --release-only`) and stores it privately in GCS without
# overwriting existing objects. The same run then publishes it: it fetches the delivered APK by exact
# generation, re-verifies it, uploads the APK first, verifies its anonymous download before the
# manifest phones read moves, verifies live channel health (`release status`), records the release
# floor (`release record`) and queues the Pixel build. `operation: publish` with `delivery-run`
# retries a delivery whose publication did not finish. The run's ledger travels across runs and
# refuses every step the spec does not allow.
on:
push:
branches: [main]
workflow_dispatch:
inputs:
ci-run:
description: Exact successful main push CI run for an automatic release cut
required: false
type: string
ci-attempt:
description: Exact CI attempt for the automatic release
required: false
default: '1'
type: string
operation:
description: Cut, prepare, deliver and publish, publish a delivery again, or reconcile a publication
type: choice
options:
- cut
- prepare
- deliver
- publish
- reconcile
default: deliver
required: true
publish-run:
description: Original failed publication run whose exact public release is being reconciled
required: false
type: string
candidate:
description: Main push run for prepare, protected build run for deliver, or optional candidate cross-check for publish
required: false
type: string
attempt:
description: Attempt of the original push (prepare), candidate (deliver), or failed publication (reconcile)
required: false
default: '1'
type: string
plan-sha256:
description: The SHA-256 of the signing plan you reviewed (required for deliver)
required: false
type: string
delivery-run:
description: The run id of a completed deliver run whose privately stored signed APK is published again (required for publish)
required: false
type: string
notes:
description: Optional release notes shown in Settings (publish only; at most 500 characters)
required: false
type: string
concurrency:
group: ${{ (github.event_name == 'push' || inputs.operation == 'cut') && format('launcher-intake-{0}', github.run_id) || 'release' }}
queue: max
permissions:
contents: read
env:
TURBO_TELEMETRY_DISABLED: "1"
STORAGE: https://storage.googleapis.com
jobs:
reserve-version:
if: github.event_name == 'push' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
permissions: {}
steps:
- name: Reserve the version for this main push
run: echo "Launcher version $((1000 + GITHUB_RUN_NUMBER)) reserved for \`$GITHUB_SHA\`." >> "$GITHUB_STEP_SUMMARY"
cut:
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'cut' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
concurrency:
group: launcher-drafts
queue: max
outputs:
source: ${{ steps.register.outputs.source }}
permissions:
actions: read
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Register the exact versioned draft
id: register
env:
GH_TOKEN: ${{ github.token }}
CI_RUN: ${{ inputs.ci-run }}
CI_ATTEMPT: ${{ inputs.ci-attempt }}
run: |
source=$(python3 scripts/ci/app_update_producer.py launcher-register "$CI_RUN" "$CI_ATTEMPT")
echo "source=$source" >> "$GITHUB_OUTPUT"
resume-cut:
needs: cut
if: needs.cut.outputs.source != ''
runs-on: ubuntu-24.04
concurrency:
group: release
queue: max
permissions:
actions: write
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Resume protected work for the registered draft
env:
GH_TOKEN: ${{ github.token }}
PUSH_RUN: ${{ fromJSON(needs.cut.outputs.source).pushRun }}
PUSH_ATTEMPT: ${{ fromJSON(needs.cut.outputs.source).pushAttempt }}
run: python3 scripts/ci/app_update_producer.py launcher-resume "$PUSH_RUN" "$PUSH_ATTEMPT"
admit-launcher:
if: github.event_name == 'workflow_dispatch' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main' && (inputs.operation == 'prepare' || inputs.operation == 'deliver')
runs-on: ubuntu-24.04
permissions:
actions: read
contents: write
outputs:
source: ${{ steps.admit.outputs.source }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
if: inputs.operation == 'deliver'
with:
name: release-candidate-${{ inputs.candidate }}-${{ inputs.attempt }}
run-id: ${{ inputs.candidate }}
github-token: ${{ github.token }}
path: ${{ runner.temp }}/prepared
- name: Bind the requested launcher to its registered release source
id: admit
env:
GH_TOKEN: ${{ github.token }}
OPERATION: ${{ inputs.operation }}
SOURCE_RUN: ${{ inputs.candidate }}
SOURCE_ATTEMPT: ${{ inputs.attempt }}
CI_RUN: ${{ inputs.ci-run }}
CI_ATTEMPT: ${{ inputs.ci-attempt }}
run: |
set -euo pipefail
if [[ "$OPERATION" == deliver ]]; then
file="$RUNNER_TEMP/prepared/unsigned-receipt.json"
SOURCE_RUN=$(jq -er '.pushRun | strings' "$file")
SOURCE_ATTEMPT=$(jq -er '.pushAttempt | strings' "$file")
fi
source=$(python3 scripts/ci/app_update_producer.py launcher-admit-build "$SOURCE_RUN" "$SOURCE_ATTEMPT" "$CI_RUN" "$CI_ATTEMPT" | jq -ce .)
echo "source=$source" >> "$GITHUB_OUTPUT"
candidate:
needs: admit-launcher
outputs:
plan-sha256: ${{ steps.plan.outputs.sha256 }}
attempt: ${{ steps.plan.outputs.attempt }}
if: github.event_name == 'workflow_dispatch' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main' && inputs.operation == 'prepare'
environment: release
permissions:
contents: read
actions: read
id-token: write
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- run: cp scripts/ci/app_update_producer.py "$RUNNER_TEMP/launcher-storage.py"
- uses: actions/checkout@v7
with:
ref: ${{ fromJSON(needs.admit-launcher.outputs.source).sourceSha }}
persist-credentials: false
- uses: ./.github/actions/setup
with:
job: release-candidate
verification: "false"
cache-verification: "false"
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
with:
cache-disabled: true
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: platform-tools platforms;android-36 build-tools;36.0.0 ndk;28.2.13676358 cmake;3.22.1
log-accepted-android-sdk-licenses: false
- run: printf '%s\n' "$ANDROID_HOME/cmake/3.22.1/bin" >> "$GITHUB_PATH"
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install speech model converter dependencies
run: |
python3 -m pip install --index-url https://download.pytorch.org/whl/cpu 'torch==2.8.0+cpu'
python3 -m pip install 'numpy==2.2.6' 'zstandard==0.23.0' 'librosa==0.11.0' 'onnx==1.21.0' 'PyYAML==6.0.2' 'tqdm==4.67.1' 'requests==2.34.2'
- name: Prepare the pinned Eliza packages
run: |
pnpm eliza
- name: Build the registered launcher on the exact source
env:
SLACK_CLIENT_ID: ${{ vars.SLACK_CLIENT_ID }}
TELEGRAM_API_ID: ${{ vars.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
ELIZAOS_VERSION_CODE: ${{ fromJSON(needs.admit-launcher.outputs.source).version }}
SOURCE_SHA: ${{ fromJSON(needs.admit-launcher.outputs.source).sourceSha }}
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
[[ "$TELEGRAM_API_ID" =~ ^[1-9][0-9]*$ && "$TELEGRAM_API_HASH" =~ ^[0-9a-fA-F]{32}$ ]] || { echo 'Android Telegram registration is unavailable.' >&2; exit 1; }
pnpm --filter @repo/app android build --release
python3 - <<'PYAPK'
import os
import re
from zipfile import ZipFile
registration = os.environ["TELEGRAM_API_HASH"]
settings = (("TELEGRAM_API_ID", os.environ["TELEGRAM_API_ID"], "false"),
("TELEGRAM_API_HASH", registration, "true"))
with ZipFile("apps/app/artifacts/launcher-release-unsigned.apk") as apk:
entry = "assets/agent/agent.mjs"
if entry not in apk.namelist():
raise SystemExit("The unsigned Android launcher lacks its resident agent.")
agent = apk.read(entry).decode("utf-8")
for name, value, secret in settings:
if not re.search(rf"""\[\s*["']{name}["']\s*,\s*["']{value}["']\s*,\s*{secret}\s*,?\s*\]""", agent):
raise SystemExit("The resident Android agent lacks its Telegram registration.")
registration_bytes = registration.encode("ascii")
if any(registration_bytes in apk.read(asset) for asset in apk.infolist()
if asset.filename.startswith("assets/public/") and not asset.is_dir()):
raise SystemExit("The Android launcher web assets contain a Telegram registration secret.")
PYAPK
- name: Build the candidate, mirror it and plan its signing
id: plan
working-directory: apps/app
env:
GH_TOKEN: ${{ github.token }}
ELIZAOS_VERSION_CODE: ${{ fromJSON(needs.admit-launcher.outputs.source).version }}
run: |
private="$RUNNER_TEMP/candidate"
mkdir -p "$private"
pnpm -s release upstream --out "$private/upstream.json"
pnpm -s release candidate --run "$private/run.json" --number "$ELIZAOS_VERSION_CODE" --attempt "$GITHUB_RUN_ATTEMPT" --apk-manifest artifacts/apk-manifest.json --upstream "$private/upstream.json"
pnpm -s release mirror --run "$private/run.json" --apk artifacts/launcher-release-unsigned.apk --to "$private"
pnpm -s release plan --run "$private/run.json" --apk artifacts/launcher-release-unsigned.apk --out "$private/plan.json" | tee "$private/plan-answer.json"
echo "sha256=$(sha256sum "$private/plan.json" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "attempt=$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
echo "Signing plan: \`$(node -p 'require(process.argv[1]).planSha256' "$private/plan-answer.json")\`" >> "$GITHUB_STEP_SUMMARY"
- id: storage_auth
uses: google-github-actions/auth@v3
with:
project_id: alpha-aosp-lab-20261024
workload_identity_provider: projects/484320254111/locations/global/workloadIdentityPools/alpha-github-release/providers/github
service_account: alpha-release-artifacts@alpha-aosp-lab-20261024.iam.gserviceaccount.com
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/devstorage.read_write
create_credentials_file: false
export_environment_variables: false
- name: Store and read back the unsigned APK at its exact private generation
env:
TOKEN: ${{ steps.storage_auth.outputs.access_token }}
GH_TOKEN: ${{ github.token }}
SOURCE_RUN: ${{ inputs.candidate }}
SOURCE_ATTEMPT: ${{ inputs.attempt }}
run: |
python3 "$RUNNER_TEMP/launcher-storage.py" launcher-store "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" "$RUNNER_TEMP/candidate"
- uses: actions/upload-artifact@v5
with:
name: release-candidate-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/candidate/unsigned-receipt.json
${{ runner.temp }}/candidate/plan.json
${{ runner.temp }}/candidate/run.json
${{ runner.temp }}/candidate/upstream.json
retention-days: ${{ inputs.ci-run && 90 || 1 }}
if-no-files-found: error
queue-delivery:
needs: candidate
if: success() && inputs.ci-run != ''
runs-on: ubuntu-24.04
permissions:
actions: write
contents: read
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Queue the protected signer for the retained plan
env:
GH_TOKEN: ${{ github.token }}
SOURCE_RUN: ${{ inputs.candidate }}
SOURCE_ATTEMPT: ${{ inputs.attempt }}
CI_RUN: ${{ inputs.ci-run }}
CI_ATTEMPT: ${{ inputs.ci-attempt }}
BUILD_ATTEMPT: ${{ needs.candidate.outputs.attempt }}
PLAN: ${{ needs.candidate.outputs.plan-sha256 }}
run: |
python3 scripts/ci/app_update_producer.py launcher-auto-deliver "$SOURCE_RUN" "$SOURCE_ATTEMPT" \
"$CI_RUN" "$CI_ATTEMPT" "$GITHUB_RUN_ID" "$BUILD_ATTEMPT" "$PLAN"
deliver:
needs: admit-launcher
if: github.event_name == 'workflow_dispatch' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main' && inputs.operation == 'deliver'
runs-on: ubuntu-latest
timeout-minutes: 90
environment: release
permissions:
contents: read
actions: read
id-token: write
steps:
- name: Validate deliver inputs
shell: bash
env:
CANDIDATE: ${{ inputs.candidate }}
PLAN_SHA256: ${{ inputs.plan-sha256 }}
run: |
set -euo pipefail
[[ "$CANDIDATE" =~ ^[1-9][0-9]*$ ]] || { echo 'The candidate input must be a positive workflow run id.' >&2; exit 1; }
[[ "$PLAN_SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo 'The plan-sha256 input must be a 64-character lowercase hex SHA-256.' >&2; exit 1; }
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup
with:
job: release-deliver
verification: "false"
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: platform-tools build-tools;36.0.0
log-accepted-android-sdk-licenses: false
- name: Prepare the pinned Eliza packages
run: |
pnpm eliza
- uses: actions/download-artifact@v5
with:
name: release-candidate-${{ inputs.candidate }}-${{ inputs.attempt }}
path: ${{ runner.temp }}/candidate
run-id: ${{ inputs.candidate }}
github-token: ${{ github.token }}
- id: unsigned_auth
uses: google-github-actions/auth@v3
with:
project_id: alpha-aosp-lab-20261024
workload_identity_provider: projects/484320254111/locations/global/workloadIdentityPools/alpha-github-release/providers/github
service_account: alpha-release-artifacts@alpha-aosp-lab-20261024.iam.gserviceaccount.com
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/devstorage.read_only
create_credentials_file: false
export_environment_variables: false
- name: Fetch the exact candidate bytes and match the reviewed plan
env:
GH_TOKEN: ${{ github.token }}
TOKEN: ${{ steps.unsigned_auth.outputs.access_token }}
CANDIDATE: ${{ inputs.candidate }}
ATTEMPT: ${{ inputs.attempt }}
PLAN_SHA256: ${{ inputs.plan-sha256 }}
run: |
python3 scripts/ci/app_update_producer.py launcher-fetch "$CANDIDATE" "$ATTEMPT" "$RUNNER_TEMP/candidate" "$PLAN_SHA256"
- name: Match the verified private candidate to the admitted source
env:
ADMITTED_SOURCE: ${{ needs.admit-launcher.outputs.source }}
run: |
jq -e --argjson source "$ADMITTED_SOURCE" \
'{pushRun,pushAttempt,sourceSha,version} == $source' "$RUNNER_TEMP/candidate/unsigned-receipt.json"
- name: Review, sign, verify and stage private delivery
working-directory: apps/app
env:
ALPHA_APP_RELEASE_KEYSTORE_B64: ${{ secrets.ALPHA_APP_RELEASE_KEYSTORE_B64 }}
ALPHA_APP_RELEASE_KEYSTORE_PASSWORD: ${{ secrets.ALPHA_APP_RELEASE_KEYSTORE_PASSWORD }}
PLAN_SHA256: ${{ inputs.plan-sha256 }}
run: |
set -euo pipefail
set +x
umask 077
ulimit -c 0
private="$RUNNER_TEMP/candidate"
run="$private/run.json"
unsigned=("$private"/alpha-phone-*-unsigned.apk)
[[ ${#unsigned[@]} == 1 && -f ${unsigned[0]} ]] || { echo 'Expected one unsigned launcher APK' >&2; exit 1; }
keys="$RUNNER_TEMP/keys"
install -d -m 700 "$keys"
trap 'rm -rf "$keys"' EXIT
printf '%s' "$ALPHA_APP_RELEASE_KEYSTORE_B64" | base64 -d > "$keys/release.p12"
chmod 600 "$keys/release.p12"
mkdir -p artifacts
apksigner="$ANDROID_HOME/build-tools/36.0.0/apksigner"
pnpm -s release review --run "$run" --plan "$private/plan.json" --plan-sha256 "$PLAN_SHA256"
pnpm -s release sign --run "$run" --plan "$private/plan.json" --apk "${unsigned[0]}" --out artifacts/launcher-release.apk --keystore "$keys/release.p12" --key-label alpha-release --apksigner "$apksigner"
rm -rf "$keys"
pnpm android verify --release-only
pnpm -s release deliver --run "$run" --apk artifacts/launcher-release.apk --apk-manifest artifacts/apk-manifest.json --to "$RUNNER_TEMP/delivered"
- id: storage_auth
uses: google-github-actions/auth@v3
with:
project_id: alpha-aosp-lab-20261024
workload_identity_provider: projects/484320254111/locations/global/workloadIdentityPools/alpha-github-release/providers/github
service_account: alpha-release-artifacts@alpha-aosp-lab-20261024.iam.gserviceaccount.com
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/devstorage.read_write
create_credentials_file: false
export_environment_variables: false
- name: Upload the signed APK to private storage, never over an existing object
shell: bash
env:
TOKEN: ${{ steps.storage_auth.outputs.access_token }}
CANDIDATE_RUN_ID: ${{ inputs.candidate }}
run: |
set -euo pipefail
set +x
umask 077
delivered="$RUNNER_TEMP/delivered"
receipt="$delivered/receipt.json"
number=$(node -p 'require(process.argv[1]).number' "$receipt")
[[ "$number" =~ ^[1-9][0-9]*$ ]] || { echo 'Invalid release number in receipt.json' >&2; exit 1; }
apk_file="$delivered/alpha-phone-${number}.apk"
[[ -f "$apk_file" ]] || { echo "Missing delivered APK: $apk_file" >&2; exit 1; }
test "$(sha256sum "$apk_file" | cut -d ' ' -f 1)" = "$(node -p 'require(process.argv[1]).sha256' "$receipt")"
bucket="alpha-aosp-lab-20261024-private-apks"
object_path="delivered/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}/alpha-phone-${number}.apk"
encoded_object=$(node -p 'encodeURIComponent(process.argv[1])' "$object_path")
curl -fsS --proto '=https' --max-redirs 0 \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/vnd.android.package-archive" \
-X POST --upload-file "$apk_file" \
-o "$RUNNER_TEMP/private-storage.json" \
"$STORAGE/upload/storage/v1/b/$bucket/o?uploadType=media&name=$encoded_object&ifGenerationMatch=0"
node -e '
const fs = require("node:fs");
const [receiptFile, storedFile, expectedBucket, expectedObject, candidateRunId, unsignedFile, outFile] = process.argv.slice(1);
const r = JSON.parse(fs.readFileSync(receiptFile, "utf8"));
const s = JSON.parse(fs.readFileSync(storedFile, "utf8"));
if (s.bucket !== expectedBucket || s.name !== expectedObject || Number(s.size) !== r.sizeBytes || typeof s.generation !== "string" || s.generation === "") {
console.error("Private storage response mismatch");
process.exit(1);
}
const out = {
public: false,
bucket: s.bucket,
object: s.name,
generation: s.generation,
bytes: Number(s.size),
sha256: r.sha256,
number: r.number,
candidateRunId: Number(candidateRunId),
unsignedCandidate: JSON.parse(fs.readFileSync(unsignedFile, "utf8")),
};
fs.writeFileSync(outFile, JSON.stringify(out, null, 2) + "\n");
' "$receipt" "$RUNNER_TEMP/private-storage.json" "$bucket" "$object_path" "$CANDIDATE_RUN_ID" "$RUNNER_TEMP/candidate/unsigned-receipt.json" "$delivered/private-storage-receipt.json"
receipts_dir="$RUNNER_TEMP/delivery-receipts"
mkdir -p "$receipts_dir"
cp "$delivered/private-storage-receipt.json" "$delivered/receipt.json" "$RUNNER_TEMP/candidate/run.json" "$RUNNER_TEMP/candidate/upstream.json" "$receipts_dir/"
test "$(find "$receipts_dir" -maxdepth 1 -type f | wc -l)" -eq 4
test "$(find "$receipts_dir" -type f -name '*.apk' | wc -l)" -eq 0
rm -f "$apk_file" apps/app/artifacts/launcher-release.apk
{
echo "Delivered release \`$number\` privately to \`gs://$bucket/$object_path\`."
echo "Signed APK SHA-256: \`$(node -p 'require(process.argv[1]).sha256' "$receipts_dir/private-storage-receipt.json")\`"
echo "Delivery run id: \`${GITHUB_RUN_ID}\`"
} >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v5
with:
name: release-delivery-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/delivery-receipts
retention-days: 14
if-no-files-found: error
publish:
needs: deliver
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main' && (inputs.operation == 'publish' || needs.deliver.result == 'success') }}
runs-on: ubuntu-latest
timeout-minutes: 90
environment: release
permissions:
contents: write
actions: read
id-token: write
env:
DELIVERY_RUN: ${{ inputs.operation == 'publish' && inputs.delivery-run || github.run_id }}
steps:
- name: Validate publish inputs
shell: bash
env:
CANDIDATE: ${{ inputs.candidate }}
run: |
set -euo pipefail
[[ "$DELIVERY_RUN" =~ ^[1-9][0-9]*$ ]] || { echo 'The delivery-run input must be the positive workflow run id of a completed deliver run.' >&2; exit 1; }
if [[ -n "$CANDIDATE" && ! "$CANDIDATE" =~ ^[1-9][0-9]*$ ]]; then
echo 'When provided, the candidate input must be a positive workflow run id.' >&2
exit 1
fi
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup
with:
job: release-publish
verification: "false"
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: platform-tools build-tools;36.0.0
log-accepted-android-sdk-licenses: false
- name: Prepare the pinned Eliza packages
run: |
pnpm eliza
- uses: actions/download-artifact@v5
with:
pattern: release-delivery-${{ env.DELIVERY_RUN }}-*
path: ${{ runner.temp }}/delivery
run-id: ${{ env.DELIVERY_RUN }}
github-token: ${{ github.token }}
- id: storage_auth
uses: google-github-actions/auth@v3
with:
project_id: alpha-aosp-lab-20261024
workload_identity_provider: projects/484320254111/locations/global/workloadIdentityPools/alpha-github-release/providers/github
service_account: alpha-release-artifacts@alpha-aosp-lab-20261024.iam.gserviceaccount.com
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/devstorage.read_only
create_credentials_file: false
export_environment_variables: false
- name: Pull the delivered signed APK from private storage and verify its receipt
shell: bash
env:
TOKEN: ${{ steps.storage_auth.outputs.access_token }}
CANDIDATE: ${{ inputs.candidate }}
run: |
set -euo pipefail
set +x
umask 077
mapfile -t dirs < <(find "$RUNNER_TEMP/delivery" -mindepth 1 -maxdepth 1 -type d -name "release-delivery-${DELIVERY_RUN}-*" | sort -V)
if [[ ${#dirs[@]} -eq 1 ]]; then
delivery_dir="${dirs[0]}"
elif [[ ${#dirs[@]} -eq 0 && -f "$RUNNER_TEMP/delivery/private-storage-receipt.json" ]]; then
delivery_dir="$RUNNER_TEMP/delivery"
else
echo "Expected one release-delivery artifact for run $DELIVERY_RUN, found ${#dirs[@]} directories" >&2
exit 1
fi
ledger_dir="$RUNNER_TEMP/ledger"
mkdir -p "$ledger_dir" apps/app/artifacts
cp "$delivery_dir/run.json" "$delivery_dir/upstream.json" "$delivery_dir/receipt.json" "$delivery_dir/private-storage-receipt.json" "$ledger_dir/"
node -e '
const fs = require("node:fs");
const [privateFile, receiptFile, runFile, expectedDeliveryRun, expectedCandidate] = process.argv.slice(1);
const p = JSON.parse(fs.readFileSync(privateFile, "utf8"));
const r = JSON.parse(fs.readFileSync(receiptFile, "utf8"));
const run = JSON.parse(fs.readFileSync(runFile, "utf8"));
if (!Number.isSafeInteger(r.number) || r.number <= 0 || !Number.isSafeInteger(r.sizeBytes) || r.sizeBytes <= 0 || typeof r.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(r.sha256)) {
console.error("Invalid delivery receipt fields");
process.exit(1);
}
if (p.public !== false || p.bucket !== "alpha-aosp-lab-20261024-private-apks") {
console.error("Unexpected private storage bucket or visibility");
process.exit(1);
}
const expectedPattern = new RegExp("^delivered/" + expectedDeliveryRun + "-[1-9][0-9]*/alpha-phone-" + r.number + "\\.apk$");
if (typeof p.object !== "string" || !expectedPattern.test(p.object)) {
console.error("Unexpected private storage object path");
process.exit(1);
}
if (typeof p.generation !== "string" || !/^[0-9]+$/.test(p.generation)) {
console.error("Invalid private storage generation");
process.exit(1);
}
if (p.sha256 !== r.sha256 || p.bytes !== r.sizeBytes || p.number !== r.number) {
console.error("Private storage receipt does not match delivery receipt");
process.exit(1);
}
if (run.state?.stage !== "Delivered" || run.state?.number !== r.number) {
console.error("Delivery ledger is not at Delivered stage for this release number");
process.exit(1);
}
if (expectedCandidate !== "" && String(p.candidateRunId) !== expectedCandidate) {
console.error("Candidate run id does not match private storage receipt");
process.exit(1);
}
' "$ledger_dir/private-storage-receipt.json" "$ledger_dir/receipt.json" "$ledger_dir/run.json" "$DELIVERY_RUN" "$CANDIDATE"
bucket=$(node -p 'require(process.argv[1]).bucket' "$ledger_dir/private-storage-receipt.json")
object=$(node -p 'encodeURIComponent(require(process.argv[1]).object)' "$ledger_dir/private-storage-receipt.json")
generation=$(node -p 'require(process.argv[1]).generation' "$ledger_dir/private-storage-receipt.json")
expected_sha=$(node -p 'require(process.argv[1]).sha256' "$ledger_dir/private-storage-receipt.json")
expected_bytes=$(node -p 'require(process.argv[1]).bytes' "$ledger_dir/private-storage-receipt.json")
curl -fsS --proto '=https' --max-redirs 0 \
-H "Authorization: Bearer $TOKEN" \
-o "apps/app/artifacts/launcher-release.apk" \
"$STORAGE/storage/v1/b/$bucket/o/$object?generation=$generation&alt=media"
actual_sha=$(sha256sum "apps/app/artifacts/launcher-release.apk" | cut -d ' ' -f 1)
actual_bytes=$(wc -c < "apps/app/artifacts/launcher-release.apk" | tr -d '[:space:]')
[[ "$actual_sha" == "$expected_sha" && "$actual_bytes" == "$expected_bytes" ]] || {
echo "Downloaded signed APK digest or size did not match private-storage-receipt.json" >&2
rm -f "apps/app/artifacts/launcher-release.apk"
exit 1
}
- name: Verify, publish, check channel health and record
working-directory: apps/app
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NOTES: ${{ inputs.notes }}
run: |
set -euo pipefail
ledger_dir="$RUNNER_TEMP/ledger"
run="$ledger_dir/run.json"
pnpm android verify --release-only
number=$(node -p 'require(process.argv[1]).state.number' "$run")
manifest="$ledger_dir/alpha-update-stable.json"
if [ -n "$RELEASE_NOTES" ]; then
pnpm -s release manifest --apk artifacts/launcher-release.apk --version "$number" --notes "$RELEASE_NOTES" --out "$manifest"
else
pnpm -s release manifest --apk artifacts/launcher-release.apk --version "$number" --out "$manifest"
fi
pnpm -s release publish --run "$run" --apk artifacts/launcher-release.apk --manifest "$manifest" --execute
pnpm -s release status
pnpm -s release record --run "$run" --manifest "$manifest"
cp aosp/signing/release-signer.json "$ledger_dir/release-signer.json"
- uses: actions/upload-artifact@v5
if: always()
with:
name: release-ledger
path: |
${{ runner.temp }}/ledger/run.json
${{ runner.temp }}/ledger/upstream.json
${{ runner.temp }}/ledger/alpha-update-stable.json
${{ runner.temp }}/ledger/release-signer.json
${{ runner.temp }}/ledger/private-storage-receipt.json
retention-days: 90
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: pixel-launcher-${{ github.run_attempt }}
path: |
${{ runner.temp }}/ledger/run.json
${{ runner.temp }}/ledger/alpha-update-stable.json
${{ runner.temp }}/ledger/private-storage-receipt.json
if-no-files-found: error
retention-days: 90
reconcile:
if: github.event_name == 'workflow_dispatch' && github.repository_id == '1396333361' && github.ref == 'refs/heads/main' && inputs.operation == 'reconcile'
environment: release
permissions:
contents: read
actions: read
checks: read
deployments: read
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Recover the archived publication and the exact delivery it consumed
env:
GH_TOKEN: ${{ github.token }}
PUBLISH_RUN: ${{ inputs.publish-run }}
ATTEMPT: ${{ inputs.attempt }}
run: python3 scripts/ci/app_update_producer.py launcher-publication-inputs "$PUBLISH_RUN" "$ATTEMPT" "$RUNNER_TEMP/ledger"
- uses: ./.github/actions/setup
with:
job: release-reconcile
verification: "false"
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
with:
packages: platform-tools build-tools;36.0.0
log-accepted-android-sdk-licenses: false
- run: pnpm eliza
- name: Read the public signed APK, reconcile the observations and record the floor
working-directory: apps/app
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
ledger="$RUNNER_TEMP/ledger"
number=$(jq -er .number "$ledger/private-storage-receipt.json")
apk="$RUNNER_TEMP/alpha-phone-$number.apk"
curl -fsSL --proto '=https' --proto-redir '=https' --max-redirs 4 --retry 2 \
"https://github.com/AlphaPhone/alpha/releases/download/app-stable-alphacompute/alpha-phone-$number.apk" -o "$apk"
manifest="$ledger/alpha-update-stable.json"
pnpm -s release publish --run "$ledger/run.json" --apk "$apk" --manifest "$manifest" --reconcile
pnpm -s release status
pnpm -s release record --run "$ledger/run.json" --manifest "$manifest"
cp aosp/signing/release-signer.json "$ledger/release-signer.json"
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: release-ledger-${{ github.run_attempt }}
path: ${{ runner.temp }}/ledger
if-no-files-found: error
retention-days: 90
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: pixel-launcher-${{ github.run_attempt }}
path: |
${{ runner.temp }}/ledger/run.json
${{ runner.temp }}/ledger/alpha-update-stable.json
${{ runner.temp }}/ledger/private-storage-receipt.json
${{ runner.temp }}/ledger/reconciliation.json
if-no-files-found: error
retention-days: 90
queue-pixel:
needs: [publish, reconcile]
if: ${{ !cancelled() && (needs.publish.result == 'success' || needs.reconcile.result == 'success') }}
runs-on: ubuntu-24.04
permissions:
actions: write
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Admit the exact published launcher before the next channel change
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/ci/app_update_producer.py launcher-queue-pixel