Build installable APKs for forked pull requests

This commit is contained in:
feedc0de committed 2026-11-23 16:50:34 +01:00
1 parent a42aa7bce8
commit c283221a11
3 files changed
+49 -25

No files matched your search

+18 -17
View File
@@ -61,25 +61,26 @@ jobs:
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: |
set -Eeuo pipefail
: "${REGISTRY_USERNAME:?REGISTRY_USERNAME secret is required to access the toolchain image}"
: "${REGISTRY_PASSWORD:?REGISTRY_PASSWORD secret is required to access the toolchain image}"
if [[ -n "$REGISTRY_USERNAME" && -n "$REGISTRY_PASSWORD" ]]; then
auth_file="${RUNNER_TEMP:-/tmp}/evcharger-registry-auth-${GITHUB_RUN_ID}.json"
export REGISTRY_AUTH_FILE="$auth_file"
trap 'rm -f -- "$auth_file"' EXIT
printf '%s' "$REGISTRY_PASSWORD" | podman login "$REGISTRY" \
--username "$REGISTRY_USERNAME" \
--password-stdin
auth_file="${RUNNER_TEMP:-/tmp}/evcharger-registry-auth-${GITHUB_RUN_ID}.json"
export REGISTRY_AUTH_FILE="$auth_file"
trap 'rm -f -- "$auth_file"' EXIT
printf '%s' "$REGISTRY_PASSWORD" | podman login "$REGISTRY" \
--username "$REGISTRY_USERNAME" \
--password-stdin
if podman pull "$BUILD_IMAGE"; then
echo "Using published toolchain image: $BUILD_IMAGE"
if podman pull "$BUILD_IMAGE"; then
echo "Using published toolchain image: $BUILD_IMAGE"
else
echo "Toolchain image is not published yet; building $BUILD_IMAGE"
podman build --pull=always --layers --tag "$BUILD_IMAGE" .
podman push "$BUILD_IMAGE"
fi
elif podman image exists "$BUILD_IMAGE"; then
echo "Using locally cached toolchain image: $BUILD_IMAGE"
else
echo "Toolchain image is not published yet; building $BUILD_IMAGE"
podman build --pull=always \
--layers \
--tag "$BUILD_IMAGE" \
.
podman push "$BUILD_IMAGE"
echo "Registry credentials are unavailable; building the toolchain locally."
podman build --pull=always --layers --tag "$BUILD_IMAGE" .
fi
- name: Build Linux development executable
+21 -2
View File
@@ -42,7 +42,7 @@ if [[ -n "${keystore_path}" ]]; then
export QT_ANDROID_KEYSTORE_KEY_PASS="${ANDROID_KEYSTORE_KEY_PASS}"
sign_android=ON
else
echo "No Android keystore configured; producing unsigned CI packages."
echo "No release keystore configured; the APK will use a temporary test key."
fi
"${qt_root}/${qt_version}/android_arm64_v8a/bin/qt-cmake" \
@@ -84,12 +84,31 @@ cp "${aab_path}" "${output_dir}/evcharger-${version_name}.aab"
readonly output_apk="evcharger-${version_name}-universal.apk"
readonly output_aab="evcharger-${version_name}.aab"
if [[ "${sign_android}" == OFF ]]; then
# Forked pull requests cannot access the release keystore. Sign their APK
# with a disposable key so the validation artifact can be installed.
test_keystore_path="${build_dir}/ci-test.keystore"
trap 'rm -f -- "${test_keystore_path}"' EXIT
rm -f -- "${test_keystore_path}"
keytool -genkeypair -noprompt \
-keystore "${test_keystore_path}" \
-storepass android -keypass android -alias ci-test \
-keyalg RSA -keysize 2048 -validity 365 \
-dname 'CN=EVCharger CI test build'
"${ANDROID_SDK_ROOT}/build-tools/36.0.0/apksigner" sign \
--ks "${test_keystore_path}" \
--ks-pass pass:android --key-pass pass:android \
--out "${output_dir}/${output_apk}.signed" \
"${output_dir}/${output_apk}"
mv "${output_dir}/${output_apk}.signed" "${output_dir}/${output_apk}"
fi
for abi in arm64-v8a armeabi-v7a; do
unzip -Z1 "${output_dir}/${output_apk}" "lib/${abi}/*" >/dev/null
done
"${ANDROID_SDK_ROOT}/build-tools/36.0.0/apksigner" verify --verbose --print-certs "${output_dir}/${output_apk}"
if [[ "${sign_android}" == ON ]]; then
"${ANDROID_SDK_ROOT}/build-tools/36.0.0/apksigner" verify --verbose --print-certs "${output_dir}/${output_apk}"
jarsigner -verify "${output_dir}/${output_aab}"
fi
+10 -6
View File
@@ -102,11 +102,16 @@ robot needs write permission so the first run of a new revision can push it.
Credentials are written to a per-job temporary authentication file and removed
before the step exits.
Forked pull requests do not receive registry secrets. Their jobs reuse a locally
cached toolchain image, or build it from the Dockerfile when needed, without
publishing it to the registry.
## Signing secrets
Without a keystore, the workflow deliberately produces unsigned validation
packages. This allows pull requests to test Android compilation without release
credentials.
Without a release keystore, the workflow signs the APK with a temporary test
key so it can be installed. Each run generates a new key, so uninstall an older
test build before installing a new one. It cannot update an app signed with the
release key. The AAB remains unsigned and is only a validation artifact.
In **Settings > Actions > Secrets**, add these repository secrets:
@@ -171,9 +176,8 @@ evcharger-aab/
Artifacts are retained for 30 days. APK and AAB packages are separate downloads
so phone testing does not also download the Play bundle. Gitea Actions serves
artifacts as ZIP archives, but compression is disabled because APK and AAB files
are already ZIP containers. A signed universal APK is suitable for sideloading;
an unsigned one is only a validation artifact. Upload the signed AAB to Google
Play, which produces device-specific APKs.
are already ZIP containers. The universal APK is suitable for sideloading. Only
upload a release-signed AAB to Google Play, which produces device-specific APKs.
The Android `versionCode` defaults to the monotonically increasing Gitea Actions
run number. Tags become the `versionName` after an optional leading `v` is