Repository navigation
215 lines (211 loc) · 11.8 KB
/
Copy pathrelease-pixel.yml
File metadata and controls
215 lines (211 loc) · 11.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
name: release-pixel
run-name: Pixel 10a ${{ inputs.purpose }} for launcher publication ${{ inputs.publish_run }}.${{ inputs.publish_attempt }}
on:
workflow_dispatch:
inputs:
purpose:
description: Production release or private physical qualification
required: false
type: choice
default: release
options: [release, qualification]
publish_run:
description: Main launcher release workflow run that published the APK
required: true
type: string
publish_attempt:
description: Its successful publish or reconcile job attempt
required: true
type: string
default: '1'
delivery_run:
description: Original signed delivery run for a publication made before Pixel input artifacts were introduced
required: false
type: string
os_ci_run:
description: Successful main push CI for a separately chosen OS source (defaults to the green launcher source)
required: false
type: string
os_ci_attempt:
description: Exact successful attempt of os_ci_run
required: false
type: string
permissions: {}
env:
PIXEL_PURPOSE: ${{ inputs.purpose || 'release' }}
jobs:
admit:
if: github.repository_id == '1396333361' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
permissions:
actions: read
contents: write
steps:
- name: Verify the successful main publication and its ancestry
id: publication
env:
GH_TOKEN: ${{ github.token }}
RUN: ${{ inputs.publish_run }}
ATTEMPT: ${{ inputs.publish_attempt }}
DELIVERY: ${{ inputs.delivery_run }}
run: |
set -euo pipefail
[[ "$RUN" =~ ^[1-9][0-9]*$ && "$ATTEMPT" =~ ^[1-9][0-9]*$ ]]
base="repos/$GITHUB_REPOSITORY/actions/runs/$RUN/attempts/$ATTEMPT"
published=$(gh api "$base" | jq -er '
select(.head_branch == "main" and .event == "workflow_dispatch" and
.path == ".github/workflows/release.yml" and .head_repository.id == 1396333361)
| .head_sha | select(test("^[0-9a-f]{40}$"))')
gh api "repos/$GITHUB_REPOSITORY/compare/$published...$GITHUB_SHA" |
jq -e --arg sha "$published" '.merge_base_commit.sha == $sha and (.status == "ahead" or .status == "identical")'
kind=$(gh api "$base/jobs" | jq -er '[.jobs[] | select((.name == "publish" or .name == "reconcile") and .conclusion == "success") | .name]
| select(length == 1) | first')
echo "kind=$kind" >> "$GITHUB_OUTPUT"
if [[ -n "$DELIVERY" ]]; then
test "$kind" = publish
[[ "$DELIVERY" =~ ^[1-9][0-9]*$ && "$ATTEMPT" == 1 ]]
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN" | jq -e '.run_attempt == 1'
receipt="repos/$GITHUB_REPOSITORY/actions/runs/$DELIVERY"
attempt=$(gh api "$receipt" | jq -er 'select(.head_branch == "main" and .event == "workflow_dispatch"
and .path == ".github/workflows/release.yml" and .head_repository.id == 1396333361
and .conclusion == "success") | .run_attempt')
gh api "$receipt/attempts/$attempt/jobs" | jq -e '[.jobs[] | select(.name == "deliver" and .conclusion == "success")] | length == 1'
gh run download "$RUN" --repo "$GITHUB_REPOSITORY" -n release-ledger -D "$RUNNER_TEMP/published"
gh run download "$DELIVERY" --repo "$GITHUB_REPOSITORY" -n "release-delivery-$DELIVERY-$attempt" -D "$RUNNER_TEMP/delivery"
cp "$RUNNER_TEMP/delivery/private-storage-receipt.json" "$RUNNER_TEMP/published/"
jq -e --arg dir "delivered/$DELIVERY-$attempt/" '.public == false and (.object | startswith($dir))' "$RUNNER_TEMP/published/private-storage-receipt.json"
fi
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
if: inputs.delivery_run == ''
with:
name: pixel-launcher-${{ inputs.publish_attempt }}
run-id: ${{ inputs.publish_run }}
github-token: ${{ github.token }}
path: ${{ runner.temp }}/published
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Bind the published manifest, public channel, delivered bytes and source candidate
id: source
env:
KIND: ${{ steps.publication.outputs.kind }}
OS_CI_RUN: ${{ inputs.os_ci_run }}
OS_CI_ATTEMPT: ${{ inputs.os_ci_attempt }}
GH_TOKEN: ${{ github.token }}
DELIVERY: ${{ inputs.delivery_run }}
run: |
set -euo pipefail
cd "$RUNNER_TEMP/published"
curl -fsSL --proto '=https' --proto-redir '=https' --max-redirs 3 \
https://github.com/AlphaPhone/alpha/releases/download/app-stable-alphacompute/alpha-update-stable.json > live.json
jq -en --slurpfile m live.json --slurpfile r private-storage-receipt.json --slurpfile l run.json '
$m[0].schema == "alpha-update/v1" and $m[0].variant == "launcher" and
$m[0].sha256 == $r[0].sha256 and $m[0].sizeBytes == $r[0].bytes and
$m[0].versionCode == $r[0].number and $l[0].state.number == $r[0].number and
$l[0].state.apkVerified == true'
if [[ "$KIND" == reconcile ]]; then
cmp -s live.json alpha-update-stable.json
jq -e '.state | .stage == "Recorded" and .pointerRead and .pointer == .number and .floor >= .number' run.json
jq -en --slurpfile r reconciliation.json --slurpfile p private-storage-receipt.json '
$r[0].publication.artifactId > 0 and $r[0].delivery.artifactId > 0 and
($r[0].delivery | "delivered/\(.run)-\(.attempt)/alpha-phone-\($p[0].number).apk") == $p[0].object'
fi
if [[ -f alpha-update-stable.json ]]; then
jq -en --slurpfile live live.json --slurpfile archived alpha-update-stable.json '$live[0] == $archived[0]'
else
test -n "$DELIVERY"
url=$(jq -er '.apkUrl | select(test("^https://github\\.com/(AlphaPhone/alpha|eliza-research/(alpha|alphaphone))/releases/download/app-stable-alphacompute/alpha-phone-[1-9][0-9]*\\.apk$"))' live.json)
expected=$(jq -er '.sha256' private-storage-receipt.json)
actual=$(curl -fsSL --proto '=https' --proto-redir '=https' --max-redirs 3 "$url" | sha256sum | cut -d' ' -f1)
test "$actual" = "$expected"
fi
selection=$(python3 "$GITHUB_WORKSPACE/scripts/ci/app_update_producer.py" launcher-pixel-source \
private-storage-receipt.json "$PIXEL_PURPOSE" "$OS_CI_RUN" "$OS_CI_ATTEMPT")
jq -er '.era | select(. == "legacy" or . == "versioned") | "era=" + .' <<< "$selection" >> "$GITHUB_OUTPUT"
jq -er '.source | select(test("^[0-9a-f]{40}$")) | "source=" + .' <<< "$selection" >> "$GITHUB_OUTPUT"
- name: Verify the selected product against the protected controller
env:
GH_TOKEN: ${{ github.token }}
PIXEL_SOURCE: ${{ steps.source.outputs.source }}
run: bash .github/actions/pixel-vm/source.sh
- name: Check the reviewed eligibility file for a private qualification
if: inputs.purpose == 'qualification'
run: test -s apps/app/aosp/pixel10a-qualification.json
- name: Keep reviewed enrollment on subsequent main releases
if: hashFiles('apps/app/aosp/pixel10a-enrollment.json') == ''
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh api "repos/$GITHUB_REPOSITORY/commits?sha=$GITHUB_SHA&path=apps/app/aosp/pixel10a-enrollment.json&per_page=1" |
jq -e 'if length == 0 then true else error("Restore the previously committed Pixel enrollment evidence") end'
- uses: ./.github/actions/setup
if: inputs.purpose == 'qualification' || hashFiles('apps/app/aosp/pixel10a-enrollment.json') != ''
with:
job: pixel-enrollment
verification: 'false'
- uses: ./.github/actions/prepare-release-tools
if: inputs.purpose == 'qualification' || hashFiles('apps/app/aosp/pixel10a-enrollment.json') != ''
- name: Verify the qualified baseline and the live production OS channel before enrollment
if: inputs.purpose == 'qualification' || hashFiles('apps/app/aosp/pixel10a-enrollment.json') != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gate=enrollment-check
if [[ "$PIXEL_PURPOSE" == qualification ]]; then gate=qualification-check; fi
pnpm --filter @repo/app -s aosp "$gate" > "$RUNNER_TEMP/pixel-enrollment.json"
publication=$(jq -er '"repos/\(env.GITHUB_REPOSITORY)/actions/runs/\(.publishRun)/attempts/\(.publishAttempt)"' "$RUNNER_TEMP/pixel-enrollment.json")
gh api "$publication" | jq -e --slurpfile enrollment "$RUNNER_TEMP/pixel-enrollment.json" '
.head_sha == $enrollment[0].publishCommit and .head_branch == "main" and
.path == ".github/workflows/release-os-ota-publish.yml" and .event == "workflow_dispatch" and
.head_repository.id == 1396333361 and .conclusion == "success"'
commit=$(jq -er '.publishCommit' "$RUNNER_TEMP/pixel-enrollment.json")
gh api "repos/$GITHUB_REPOSITORY/compare/$commit...$GITHUB_SHA" |
jq -e --arg commit "$commit" '.merge_base_commit.sha == $commit'
manifest=$(jq -er '.manifestFile | strings' "$RUNNER_TEMP/pixel-enrollment.json")
if [[ "$PIXEL_PURPOSE" == qualification ]]; then
read -r run attempt < <(jq -r '[.publishRun,.publishAttempt] | @tsv' "$RUNNER_TEMP/pixel-enrollment.json")
gh run download "$run" --repo "$GITHUB_REPOSITORY" -n "os-publish-ledger-$run-$attempt" -D "$RUNNER_TEMP/prior-os"
jq -en --slurpfile approved "$manifest" --slurpfile published "$RUNNER_TEMP/prior-os/alpha-os-update.json" '$approved == $published'
fi
timestamp=$(jq -er '.buildTimestamp | select(type == "number" and . > 0)' "$manifest")
id=$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/os-pilot" --jq '.id')
gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/releases/$id/assets?per_page=100" |
jq -e --slurpfile baseline "$manifest" '
[ .[][] | select(.state == "uploaded" and .browser_download_url == $baseline[0].url and
.digest == ("sha256:" + $baseline[0].sha256) and .size == $baseline[0].sizeBytes) ] | length == 1'
pnpm --filter @repo/app -s release os-status --min-timestamp "$timestamp" |
jq -e --slurpfile baseline "$manifest" '
(.buildFingerprint | endswith(":user/release-keys")) and
(.buildTimestamp > $baseline[0].buildTimestamp or
(.buildTimestamp == $baseline[0].buildTimestamp and .sha256 == $baseline[0].sha256))'
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: pixel-delivery-${{ github.run_attempt }}
path: ${{ runner.temp }}/published/private-storage-receipt.json
if-no-files-found: error
retention-days: 90
- id: attempt
run: echo "number=$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
outputs:
era: ${{ steps.source.outputs.era }}
source: ${{ steps.source.outputs.source }}
attempt: ${{ steps.attempt.outputs.number }}
compute:
needs: admit
concurrency:
group: alpha-production-pixel-compute
queue: max
permissions:
actions: write
contents: read
id-token: write
uses: ./.github/workflows/pixel-compute.yml
with:
source: ${{ needs.admit.outputs.source }}
era: ${{ needs.admit.outputs.era }}
attempt: ${{ needs.admit.outputs.attempt }}
purpose: ${{ inputs.purpose || 'release' }}
os_ci_run: ${{ inputs.os_ci_run }}
os_ci_attempt: ${{ inputs.os_ci_attempt }}