43 lines
2.7 KiB
Bash
43 lines
2.7 KiB
Bash
#!/usr/bin/env bash
|
|
# Called by android.yml once per variant so verified harness artifacts upload first.
|
|
set -euo pipefail
|
|
variant="$1"
|
|
case "$variant" in
|
|
harness) harness=true ;;
|
|
production) harness=false ;;
|
|
*) echo "Expected harness or production" >&2; exit 2 ;;
|
|
esac
|
|
out="dist/android/$variant"
|
|
cargo run --locked -p xtask -- build --target "$TARGET" --llvm-dir "$LLVM_HOME" --skia-source "$SKIA_SOURCE_DIR" --test-harness "$harness" --jobs "${CARGO_BUILD_JOBS:-1}"
|
|
# Explicit online dependency resolution supports a fresh Gradle cache.
|
|
# Bootstrap still requires the local checksum-pinned zip; SDK downloads stay disabled.
|
|
cargo run --locked -p xtask -- package --target "$TARGET" --out "$out" --test-harness "$harness" --gradle-online true
|
|
cargo run --locked -p xtask -- verify-package --target "$TARGET" --out "$out" --test-harness "$harness"
|
|
cp "$CARGO_TARGET_DIR/$TARGET/release/native-build.json" "$out/$TARGET/native-build.json"
|
|
cp native/native-deps.lock.json "$out/$TARGET/native-deps.lock.json"
|
|
cp "target/native-deps/$TARGET/provenance.json" "$out/$TARGET/dependency-provenance.json"
|
|
python3 - "$out" "$harness" <<'PY'
|
|
import hashlib, json, os, pathlib, subprocess, sys
|
|
out = pathlib.Path(sys.argv[1])
|
|
harness = sys.argv[2] == 'true'
|
|
target = os.environ['TARGET']
|
|
revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
|
|
assert revision == os.environ['EXPECTED_REVISION'], 'checkout revision changed'
|
|
receipt = json.loads((out / target / 'package-report.json').read_text())
|
|
verification = json.loads((out / target / 'verification.json').read_text())
|
|
assert receipt['testOnly'] == harness and receipt['sourceBuild']['testHarness'] == harness
|
|
assert verification['passed'] is True
|
|
assert {a['kind'] for a in receipt['artifacts']} == ({'apk'} if harness else {'apk', 'aab'})
|
|
assert all(a['signing'] == ('android-debug-test' if harness else 'unsigned-not-installable') and not a['release_eligible'] for a in receipt['artifacts'])
|
|
files = [out / a['name'] for a in receipt['artifacts']]
|
|
files += [out / target / name for name in ('package-report.json', 'verification.json', 'native-build.json', 'native-deps.lock.json', 'dependency-provenance.json')]
|
|
hashes = {}
|
|
for path in files:
|
|
with path.open('rb') as source:
|
|
digest = hashlib.sha256()
|
|
for chunk in iter(lambda: source.read(1024 * 1024), b''):
|
|
digest.update(chunk)
|
|
hashes[str(path.relative_to(out))] = digest.hexdigest()
|
|
(out / 'build-info.json').write_text(json.dumps({'schema': 1, 'revision': revision, 'run_id': os.environ['CI_RUN_ID'], 'target': target, 'testHarness': harness, 'gradleOnline': True, 'deviceAcceptance': 'not exercised', 'publicationAuthorized': False, 'sha256': hashes}, indent=2) + '\n')
|
|
PY
|