BigBrainParking/app/plugins/withReleaseSigning.js
Hank 1dede50995 Initial commit: parksmarter-client + BigBrainParking app
Reverse-engineered ParkSmarter API client (TypeScript, live-verified) plus a
de-Googled Expo/React Native app for GrapheneOS: MapLibre meter map with GPS,
VisionCamera QR kiosk scanning with save/share, local session-expiry reminders,
UnifiedPush wiring, and Gitea CI to publish signed APKs for Obtainium.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 08:33:47 -07:00

46 lines
1.7 KiB
JavaScript

/**
* Expo config plugin: inject a release signingConfig into android/app/build.gradle
* that reads credentials from environment variables (set by CI). This survives
* `expo prebuild --clean`, so signed builds are reproducible without committing
* the generated android/ directory.
*
* Env vars (see .gitea/workflows/build-apk.yml):
* BBP_UPLOAD_STORE_FILE, BBP_UPLOAD_STORE_PASSWORD,
* BBP_UPLOAD_KEY_ALIAS, BBP_UPLOAD_KEY_PASSWORD
*
* If the env vars are absent (local dev), the build falls back to the debug key.
*/
const { withAppBuildGradle } = require('@expo/config-plugins');
const SIGNING_BLOCK = `
release {
def storeFilePath = System.getenv("BBP_UPLOAD_STORE_FILE")
if (storeFilePath != null) {
storeFile file(storeFilePath)
storePassword System.getenv("BBP_UPLOAD_STORE_PASSWORD")
keyAlias System.getenv("BBP_UPLOAD_KEY_ALIAS")
keyPassword System.getenv("BBP_UPLOAD_KEY_PASSWORD")
}
}`;
module.exports = function withReleaseSigning(config) {
return withAppBuildGradle(config, (cfg) => {
let gradle = cfg.modResults.contents;
// 1) Add a `release` signingConfig next to the default `debug` one.
if (!gradle.includes('BBP_UPLOAD_STORE_FILE')) {
gradle = gradle.replace(
/signingConfigs \{/,
`signingConfigs {${SIGNING_BLOCK}`,
);
// 2) Point the release buildType at it *only* when the keystore env is set.
gradle = gradle.replace(
/(buildTypes \{[\s\S]*?release \{)/,
`$1\n if (System.getenv("BBP_UPLOAD_STORE_FILE") != null) { signingConfig signingConfigs.release }`,
);
}
cfg.modResults.contents = gradle;
return cfg;
});
};