refactor(android): consolidate signing config and bump SDK to 36
- Remove external android-signing.gradle.kts, inline keystore config into app/build.gradle.kts - Update compileSdk and targetSdk to 36 - Fix version format in package.json (v0.1 → 0.1.0)
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "bookmgr-client",
|
"name": "bookmgr-client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "v0.1",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -1,28 +1,60 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Patch the generated Android build.gradle.kts with signing configuration.
|
# Patch the generated Android build.gradle.kts with signing + per-arch release builds.
|
||||||
# Run this after `tauri android init` if the signing config is missing.
|
# Run this after `tauri android init` if the gen/android/ directory was regenerated.
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
BUILD_FILE="src-tauri/gen/android/app/build.gradle.kts"
|
BUILD_FILE="src-tauri/gen/android/app/build.gradle.kts"
|
||||||
SIGNING_FILE="src-tauri/android-signing.gradle.kts"
|
|
||||||
|
|
||||||
if [ ! -f "$BUILD_FILE" ]; then
|
if [ ! -f "$BUILD_FILE" ]; then
|
||||||
echo "Error: $BUILD_FILE not found. Run 'tauri android init' first."
|
echo "Error: $BUILD_FILE not found. Run 'tauri android init' first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if signing is already configured
|
|
||||||
if grep -q "keystoreProperties" "$BUILD_FILE" 2>/dev/null; then
|
if grep -q "keystoreProperties" "$BUILD_FILE" 2>/dev/null; then
|
||||||
echo "Signing already configured in $BUILD_FILE"
|
echo "Patch already applied."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Insert signing config block: find `signingConfigs` or add it before `buildTypes`,
|
# 1. Add keystore properties loading after the tauriProperties block
|
||||||
# then add `signingConfig` to the release buildType.
|
sed -i '/^val tauriProperties/,/^$/{
|
||||||
# Strategy: replace the entire android block content using the external apply approach.
|
/^$/a\
|
||||||
|
\
|
||||||
|
// Release signing config\
|
||||||
|
val keystorePropertiesFile = java.io.File("/home/msksbr/Android/keystore.properties")\
|
||||||
|
val keystoreProperties = Properties().apply {\
|
||||||
|
if (keystorePropertiesFile.exists()) {\
|
||||||
|
keystorePropertiesFile.inputStream().use { load(it) }\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
}' "$BUILD_FILE"
|
||||||
|
|
||||||
# Inject the apply-line at end of file (before the tauri.build.gradle.kts apply)
|
# 2. Add signingConfigs block inside the android block, before buildTypes
|
||||||
sed -i 's|apply(from = "tauri.build.gradle.kts")|apply(from = "../../../android-signing.gradle.kts")\napply(from = "tauri.build.gradle.kts")|' "$BUILD_FILE"
|
sed -i '/buildTypes {/i\ signingConfigs {\
|
||||||
|
if (keystorePropertiesFile.exists()) {\
|
||||||
|
create("release") {\
|
||||||
|
storeFile = java.io.File(keystoreProperties["storeFile"] as String)\
|
||||||
|
storePassword = keystoreProperties["storePassword"] as String\
|
||||||
|
keyAlias = keystoreProperties["keyAlias"] as String\
|
||||||
|
keyPassword = keystoreProperties["keyPassword"] as String\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
' "$BUILD_FILE"
|
||||||
|
|
||||||
|
# 3. Add signingConfig to the release buildType
|
||||||
|
sed -i '/getByName("release") {/a\ if (keystorePropertiesFile.exists()) {\
|
||||||
|
signingConfig = signingConfigs.getByName("release")\
|
||||||
|
}' "$BUILD_FILE"
|
||||||
|
|
||||||
|
# 4. Add per-arch release APK build task dependency
|
||||||
|
cat >> "$BUILD_FILE" << 'TASKDEP'
|
||||||
|
|
||||||
|
// Also build per-architecture release APKs when universal release is built
|
||||||
|
tasks.whenTaskAdded {
|
||||||
|
if (name == "assembleUniversalRelease") {
|
||||||
|
dependsOn("assembleArm64Release", "assembleArmRelease")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TASKDEP
|
||||||
|
|
||||||
echo "Signing config patched into $BUILD_FILE"
|
echo "Signing config patched into $BUILD_FILE"
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
// Android signing configuration — reads keystore credentials from external file.
|
|
||||||
// This file is kept outside gen/android/ so it survives tauri android init regeneration.
|
|
||||||
//
|
|
||||||
// Usage: add `apply(from = "../../../android-signing.gradle.kts")` at the bottom of
|
|
||||||
// src-tauri/gen/android/app/build.gradle.kts
|
|
||||||
|
|
||||||
import java.util.Properties
|
|
||||||
|
|
||||||
val keystorePropertiesFile = java.io.File("/home/msksbr/Android/keystore.properties")
|
|
||||||
val keystoreProperties = Properties().apply {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
keystorePropertiesFile.inputStream().use { load(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
signingConfigs {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
create("release") {
|
|
||||||
storeFile = java.io.File(keystoreProperties["storeFile"] as String)
|
|
||||||
storePassword = keystoreProperties["storePassword"] as String
|
|
||||||
keyAlias = keystoreProperties["keyAlias"] as String
|
|
||||||
keyPassword = keystoreProperties["keyPassword"] as String
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
getByName("release") {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
signingConfig = signingConfigs.getByName("release")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,12 +13,11 @@ val tauriProperties = Properties().apply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signing config — reads from external keystore.properties
|
// Release signing config
|
||||||
val keystorePropertiesFile = file("/home/msksbr/Android/keystore.properties")
|
val keystorePropertiesFile = file("/home/msksbr/Android/keystore.properties")
|
||||||
val keystoreProperties = Properties().apply {
|
val keystoreProperties = Properties()
|
||||||
if (keystorePropertiesFile.exists()) {
|
if (keystorePropertiesFile.exists()) {
|
||||||
keystorePropertiesFile.inputStream().use { load(it) }
|
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -89,4 +88,11 @@ dependencies {
|
|||||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(from = "tauri.build.gradle.kts")
|
apply(from = "tauri.build.gradle.kts")
|
||||||
|
|
||||||
|
// Also build per-architecture release APKs when universal release is built
|
||||||
|
afterEvaluate {
|
||||||
|
tasks.matching { it.name == "assembleUniversalRelease" }.configureEach {
|
||||||
|
dependsOn("assembleArm64Release", "assembleArmRelease", "assembleX86_64Release", "assembleX86Release")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user