50 lines
3.3 KiB
Bash
50 lines
3.3 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"
|
|
if [[ "${TEAMSPEACH_ANDROID_LOW_MEMORY:-false}" == true ]]; then
|
|
[[ "$TARGET" == aarch64-linux-android ]] || { echo 'Low-memory CI mode is Android ARM64 only' >&2; exit 1; }
|
|
export RUSTC_WORKSPACE_WRAPPER="$PWD/.gitea/android-rustc-low-memory.sh"
|
|
fi
|
|
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
|
|
# xtask package already verifies the completed APK/AAB before returning success.
|
|
# The receipt and artifact hashes below bind that verification to the uploaded bytes.
|
|
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()
|
|
low_memory = os.environ.get('TEAMSPEACH_ANDROID_LOW_MEMORY') == 'true'
|
|
optimization = {'scope': 'teamspeach_native/aarch64-linux-android', 'codegenUnits': 256, 'lto': 'off'} if low_memory else {'scope': 'workspace release defaults'}
|
|
(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, 'optimization': optimization, 'deviceAcceptance': 'not exercised', 'publicationAuthorized': False, 'sha256': hashes}, indent=2) + '\n')
|
|
PY
|