who_need_help/scripts/android-public-ci.sh

79 lines
2.7 KiB
Bash
Executable File

#!/bin/sh
set -eu
umask 077
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
workspace=$(mktemp -d "${TMPDIR:-/tmp}/wnh-android-public-ci.XXXXXX")
signing_dir="$workspace/signing"
environment_file="$workspace/development.env"
output_dir="$workspace/output"
key_alias=who-need-help-ci-development
base_url=https://android-development-ci.invalid
WNH_ANDROID_SIGNING_KEY_ALIAS=$key_alias
export WNH_ANDROID_SIGNING_KEY_ALIAS
cleanup() {
rm -rf "$workspace"
}
trap cleanup EXIT HUP INT TERM
WNH_ANDROID_SIGNING_DIR="$signing_dir" \
WNH_ANDROID_SIGNING_BASENAME=who-need-help-development \
WNH_ANDROID_SIGNING_KEY_ALIAS="$key_alias" \
WNH_ANDROID_SIGNING_SUBJECT="CN=Who Need Help CI development key" \
"$ROOT/scripts/init-android-release-signing.sh" >/dev/null
fingerprint=$(
"$ROOT/scripts/android-signing-fingerprint.sh" \
"$signing_dir/who-need-help-development.p12" \
"$signing_dir/who-need-help-development.password" \
"$key_alias"
)
printf '%s\n' \
'DEPLOYMENT_ENV=development' \
'PHX_HOST=android-development-ci.invalid' \
'PHX_SCHEME=https' \
'PHX_URL_PORT=443' \
"WNH_BASE_URL=$base_url" \
"WNH_DEBUG_BASE_URL=$base_url" \
'WNH_TRACKING_MIN_TIME_MS=5000' \
'WNH_TRACKING_HTTP_TIMEOUT_MS=15000' \
'WNH_ANDROID_VERSION_CODE=1' \
'WNH_ANDROID_VERSION_NAME=0.1.0-ci' \
"WNH_ANDROID_DEVELOPMENT_SIGNING_KEY_ALIAS=$key_alias" \
'ANDROID_APP_LINKS_PACKAGE_NAME=org.whoneedhelp.mobile.development' \
"ANDROID_APP_LINKS_SHA256_CERT_FINGERPRINTS=$fingerprint" \
>"$environment_file"
chmod 600 "$environment_file"
"$ROOT/scripts/validate-android-environment.sh" \
"$environment_file" \
development
docker build \
--secret "id=android_nonproduction_keystore,src=$signing_dir/who-need-help-development.p12" \
--secret "id=android_nonproduction_password,src=$signing_dir/who-need-help-development.password" \
--secret "id=android_nonproduction_alias,env=WNH_ANDROID_SIGNING_KEY_ALIAS" \
--build-arg "WNH_BASE_URL=$base_url" \
--build-arg WNH_TRACKING_MIN_TIME_MS=5000 \
--build-arg WNH_TRACKING_HTTP_TIMEOUT_MS=15000 \
--build-arg WNH_ANDROID_VERSION_CODE=1 \
--build-arg WNH_ANDROID_VERSION_NAME=0.1.0-ci \
--build-arg WNH_PUBLIC_BUILD_TYPE=development \
--build-arg WNH_EXPECTED_APPLICATION_ID=org.whoneedhelp.mobile.development \
--target public-artifact \
--output "type=local,dest=$output_dir" \
"$ROOT/android"
"$ROOT/scripts/android-app-links-verify.sh" \
"$environment_file" \
"$output_dir"
test -s "$output_dir/who-need-help-development.apk"
test -s "$output_dir/who-need-help-development-androidTest.apk"
test -s "$output_dir/lint-results-development.html"
echo "Ephemeral signed Android development pipeline passed."