Skip to content

Commit 492017b

Browse files
committed
Verify draft DMG from its original build with read-only Actions access
1 parent 0bcad9c commit 492017b

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎.github/workflows/installer-smoke.yml‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
permissions:
1212
contents: read
13+
actions: read
1314

1415
jobs:
1516
macos:
@@ -30,7 +31,30 @@ jobs:
3031
run: |
3132
[[ "$CANDIDATE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]
3233
mkdir "$RUNNER_TEMP/installer-assets"
33-
gh release download "$CANDIDATE_TAG" --dir "$RUNNER_TEMP/installer-assets" --pattern '*_aarch64.dmg' --pattern SHA256SUMS
34+
if ! gh release download "$CANDIDATE_TAG" --dir "$RUNNER_TEMP/installer-assets" --pattern '*_aarch64.dmg' --pattern SHA256SUMS; then
35+
# Read-only tokens cannot see private drafts. Retrieve the same DMG
36+
# from its original build and verify the recorded release hash.
37+
source_run_id=$(python3 - <<'PY'
38+
import json, os
39+
from pathlib import Path
40+
report = json.loads(Path(f"docs/releases/{os.environ['CANDIDATE_TAG']}-local-validation.json").read_text())
41+
assert 'v' + report['version'] == os.environ['CANDIDATE_TAG']
42+
print(report['releaseRun'].rsplit('/', 1)[1])
43+
PY
44+
)
45+
[[ "$source_run_id" =~ ^[0-9]+$ ]]
46+
gh run download "$source_run_id" --name macos-package --dir "$RUNNER_TEMP/installer-assets"
47+
python3 - <<'PY'
48+
import hashlib, json, os
49+
from pathlib import Path
50+
report = json.loads(Path(f"docs/releases/{os.environ['CANDIDATE_TAG']}-local-validation.json").read_text())
51+
assets = Path(os.environ['RUNNER_TEMP']) / 'installer-assets'
52+
name = f"Multi.Codex_{report['version']}_aarch64.dmg"
53+
expected = report['artifacts'][name]
54+
assert hashlib.sha256((assets / name).read_bytes()).hexdigest() == expected
55+
(assets / 'SHA256SUMS').write_text(f'{expected} {name}\n')
56+
PY
57+
fi
3458
- name: Install and update the real DMG in disposable profiles
3559
env:
3660
CANDIDATE_TAG: ${{ inputs.tag }}

0 commit comments

Comments
 (0)