Publish a signed Android APK with GitHub releases
Build the ARM64 app on version tags alongside the desktop builds. Stamp the APK with the tag version and the Release workflow run number so that updates advance and reruns keep the same code. Sign with the repository's persistent PKCS12 key in a separate step. Only the verified APK goes into the run artifact and the release. Require it for both creation and reruns. Use the same NDK for Cargo and Gradle's native strip step. Check the actual APK's package, version, release mode, ARM64 library, alignment and signature. Keep local debug version defaults. Document the two signing secrets, key backup and the effect of switching from the debug build on a mesh identity. On macOS, built the debug and release APKs, signed the release with a throwaway key, and verified its certificate. Checked rejection of missing credentials, a wrong password, an unsigned APK, a debug APK, incorrect versions and an unstripped native library. Exercised the release-create and rerun paths with a local gh stand-in, including a missing artifact. Actionlint, ShellCheck, cargo fmt, locked all-target workspace Clippy with warnings denied, and workspace tests passed (547 passed, 2 ignored). No live release or signing credentials were created in GitHub.
This commit is contained in:
1 parent
ef67e1c0ae
commit
429fa36e3e
5 files changed
+139
-7
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
apk=${1:?expected an APK}
|
||||
version_name=${2:?expected the release version}
|
||||
version_code=${3:?expected the Android version code}
|
||||
build_tools=${4:?expected the Android SDK Build Tools directory}
|
||||
|
||||
badging=$("$build_tools/aapt" dump badging "$apk")
|
||||
package="package: name='cy.hexor.tsunagi' versionCode='$version_code' versionName='$version_name'"
|
||||
if [[ "$badging" != "$package "* ]]; then
|
||||
echo "Expected tsunagi $version_name (version code $version_code) in the APK manifest" >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -Fxq 'application-debuggable' <<< "$badging"; then
|
||||
echo "The release APK enables Android debugging" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -Fxq "native-code: 'arm64-v8a'" <<< "$badging"; then
|
||||
echo "Expected an arm64-v8a APK" >&2
|
||||
exit 1
|
||||
fi
|
||||
library=$(mktemp)
|
||||
trap 'rm -f "$library"' EXIT
|
||||
unzip -p "$apk" lib/arm64-v8a/libtsunagi_android.so > "$library"
|
||||
if [[ "$(LC_ALL=C file -b "$library")" != *"ARM aarch64"*", stripped"* ]]; then
|
||||
echo "Expected a stripped ARM64 tsunagi native library" >&2
|
||||
exit 1
|
||||
fi
|
||||
"$build_tools/zipalign" -c -P 16 4 "$apk"
|
||||
"$build_tools/apksigner" verify --verbose --print-certs "$apk"
|
||||
Reference in new issue
Block a user