fix(android): remove broken Gradle signing patch, sign APK with apksigner only
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
61
.github/scripts/patch-android-gradle.mjs
vendored
61
.github/scripts/patch-android-gradle.mjs
vendored
@@ -1,61 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.resolve(__dirname, "../..");
|
||||
const gradlePath = path.join(
|
||||
root,
|
||||
"template/src-tauri/gen/android/app/build.gradle.kts",
|
||||
);
|
||||
|
||||
if (!fs.existsSync(gradlePath)) {
|
||||
console.log("Android gradle file not found, skipping patch");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let content = fs.readFileSync(gradlePath, "utf8");
|
||||
|
||||
if (content.includes("signingConfigs")) {
|
||||
console.log("Android gradle already has signingConfigs");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!content.includes("import java.util.Properties")) {
|
||||
content = content.replace(
|
||||
/^(import .+\n)+/m,
|
||||
(block) => `${block}import java.util.Properties\nimport java.io.FileInputStream\n`,
|
||||
);
|
||||
}
|
||||
|
||||
const signingBlock = `
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["password"] as String
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["password"] as String
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
if (content.includes("buildTypes {")) {
|
||||
content = content.replace("buildTypes {", `${signingBlock}\n buildTypes {`);
|
||||
}
|
||||
|
||||
if (!content.includes('signingConfig = signingConfigs.getByName("release")')) {
|
||||
content = content.replace(
|
||||
/getByName\("release"\)\s*\{/,
|
||||
`getByName("release") {
|
||||
signingConfig = signingConfigs.getByName("release")`,
|
||||
);
|
||||
}
|
||||
|
||||
fs.writeFileSync(gradlePath, content);
|
||||
console.log("Patched Android gradle signing configuration");
|
||||
9
.github/scripts/setup-android-signing.sh
vendored
9
.github/scripts/setup-android-signing.sh
vendored
@@ -27,13 +27,4 @@ export WEB2APP_ANDROID_STORE_PASS="${STORE_PASS}"
|
||||
export WEB2APP_ANDROID_KEY_PASS="${KEY_PASS}"
|
||||
export WEB2APP_ANDROID_KEY_ALIAS="${KEY_ALIAS}"
|
||||
|
||||
ANDROID_DIR="template/src-tauri/gen/android"
|
||||
if [ -d "${ANDROID_DIR}" ]; then
|
||||
cat > "${ANDROID_DIR}/keystore.properties" <<EOF
|
||||
keyAlias=${KEY_ALIAS}
|
||||
password=${KEY_PASS}
|
||||
storeFile=${KEYSTORE_PATH}
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "Android signing material ready at ${KEYSTORE_PATH}"
|
||||
|
||||
11
.github/workflows/build-app.yml
vendored
11
.github/workflows/build-app.yml
vendored
@@ -117,17 +117,6 @@ jobs:
|
||||
env:
|
||||
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION }}
|
||||
|
||||
- name: Setup Android signing
|
||||
run: bash .github/scripts/setup-android-signing.sh
|
||||
env:
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
|
||||
- name: Patch Android Gradle signing
|
||||
run: node .github/scripts/patch-android-gradle.mjs
|
||||
|
||||
- name: Build Android APK
|
||||
working-directory: template
|
||||
run: npm run tauri android build -- --apk
|
||||
|
||||
Reference in New Issue
Block a user