blob: 588caa29a2d97bf4a444c67770e96a36685ddd6e (
plain)
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
|
#!/usr/bin/env bash
# Build and sign a release APK with the maintainer key.
#
# Signing is done with the Android SDK apksigner rather than AGP: AGP adds a
# "Dependency metadata" (PKDS) block to the APK signing block, which F-Droid's
# scanner rejects. The content of the APK is unchanged either way.
#
# Needs keystore.properties in the repo root (git-ignored), with:
# storeFile=... storePassword=... keyAlias=... keyPassword=...
set -euo pipefail
cd "$(dirname "$0")/.."
PROPS=keystore.properties
if [ ! -f "$PROPS" ]; then
echo "Missing $PROPS (keystore path + passwords). See README-BACKUP.txt." >&2
exit 1
fi
VERSION=$(sed -nE 's/.*versionName *= *"(.*)".*/\1/p' app/build.gradle.kts | head -1)
KS=$(sed -nE 's/^storeFile=(.*)$/\1/p' "$PROPS")
ALIAS=$(sed -nE 's/^keyAlias=(.*)$/\1/p' "$PROPS")
export RECCOON_STORE_PASS=$(sed -nE 's/^storePassword=(.*)$/\1/p' "$PROPS")
export RECCOON_KEY_PASS=$(sed -nE 's/^keyPassword=(.*)$/\1/p' "$PROPS")
SDK="${ANDROID_HOME:-$(sed -nE 's/^sdk\.dir=(.*)$/\1/p' local.properties)}"
APKSIGNER=$(ls -1 "$SDK"/build-tools/*/apksigner 2>/dev/null | sort -V | tail -1)
if [ ! -x "$APKSIGNER" ]; then
echo "apksigner not found under $SDK/build-tools" >&2
exit 1
fi
echo "==> Building unsigned release ($VERSION)"
./gradlew :app:assembleRelease
UNSIGNED=app/build/outputs/apk/release/app-release-unsigned.apk
[ -f "$UNSIGNED" ] || UNSIGNED=app/build/outputs/apk/release/app-release.apk
OUT="releases/RECCoon-${VERSION}.apk"
mkdir -p releases dist
echo "==> Signing with $APKSIGNER"
"$APKSIGNER" sign --ks "$KS" --ks-key-alias "$ALIAS" \
--ks-pass env:RECCOON_STORE_PASS --key-pass env:RECCOON_KEY_PASS \
--out "$OUT" "$UNSIGNED"
cp "$OUT" dist/
echo "==> Result"
"$APKSIGNER" verify --print-certs "$OUT" | grep -E "DN:|SHA-256 digest" | head -3
sha256sum "$OUT"
|