62 lines
2.0 KiB
Bash
62 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
# Подключает release-подпись APK через keystore.properties + Gradle script.
|
|
set -euo pipefail
|
|
|
|
ANDROID_GEN="${1:-/workspace/tauri_app/src-tauri/gen/android}"
|
|
SECRETS_DIR="${ANDROID_SECRETS_DIR:-/workspace/tauri_app/.secrets}"
|
|
KEYSTORE_FILE="${ANDROID_KEYSTORE_FILE:-${SECRETS_DIR}/lendry-id-release.keystore}"
|
|
APP_GRADLE="${ANDROID_GEN}/app/build.gradle.kts"
|
|
KEYSTORE_PROPS="${ANDROID_GEN}/keystore.properties"
|
|
SIGNING_SCRIPT="${ANDROID_GEN}/app/release-signing.gradle.kts"
|
|
PROPS_TEMPLATE="${SECRETS_DIR}/keystore.properties.template"
|
|
|
|
if [[ ! -d "${ANDROID_GEN}" ]]; then
|
|
echo "Android project not found: ${ANDROID_GEN}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "${KEYSTORE_FILE}" ]]; then
|
|
echo "Keystore не найден: ${KEYSTORE_FILE}. Запустите ensure-android-keystore.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -f "${PROPS_TEMPLATE}" ]]; then
|
|
cp "${PROPS_TEMPLATE}" "${KEYSTORE_PROPS}"
|
|
else
|
|
echo "keystore.properties.template не найден в ${SECRETS_DIR}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
chmod 600 "${KEYSTORE_PROPS}" || true
|
|
|
|
cat > "${SIGNING_SCRIPT}" <<'EOF'
|
|
import com.android.build.api.dsl.ApplicationExtension
|
|
import java.util.Properties
|
|
|
|
val keystoreProperties = Properties().apply {
|
|
rootProject.file("keystore.properties").inputStream().use { load(it) }
|
|
}
|
|
|
|
extensions.configure<ApplicationExtension>("android") {
|
|
signingConfigs {
|
|
create("release") {
|
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
|
storeFile = rootProject.file(keystoreProperties.getProperty("storeFile"))
|
|
storePassword = keystoreProperties.getProperty("storePassword")
|
|
}
|
|
}
|
|
buildTypes {
|
|
getByName("release") {
|
|
signingConfig = signingConfigs.getByName("release")
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
if ! grep -q 'release-signing.gradle.kts' "${APP_GRADLE}"; then
|
|
printf '\napply(from = "release-signing.gradle.kts")\n' >> "${APP_GRADLE}"
|
|
fi
|
|
|
|
echo "==> Android release signing patched (${KEYSTORE_PROPS})"
|