BigBrainParking/app/plugins/withReleaseSigning.js
Hank a8ba1fcae4
Some checks failed
build-apk / build (push) Failing after 5m9s
Release signing fix + Obtainium install guide + publish script
- Fix withReleaseSigning: RN template's unconditional debug signingConfig was
  overriding the release key. Now uses the release key when BBP_UPLOAD_* is set
  (verified: APK signed CN=BigBrainParking), else debug.
- INSTALL.md: dead-simple Obtainium setup (one-tap obtainium:// link + manual
  Forgejo-source steps). README links it.
- scripts/publish-release.sh: create a Forgejo release + upload the signed APK.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 13:27:19 -07:00

48 lines
1.9 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 the release key when its env is set, else
// debug. Replace the RN template's unconditional debug line inside the
// release {} block (otherwise it overrides the release config).
gradle = gradle.replace(
/(release \{[\s\S]*?)signingConfig signingConfigs\.debug/,
`$1signingConfig System.getenv("BBP_UPLOAD_STORE_FILE") != null ? signingConfigs.release : signingConfigs.debug`,
);
}
cfg.modResults.contents = gradle;
return cfg;
});
};