Files
musicshare/apps/mobile/plugins/withReleaseSigning.js
T
chrisandClaude Opus 5.5 a4dad724ad
CI / check (push) Canceled after 0s
Get the repo ready for F-Droid
- License: AGPL-3.0-or-later (LICENSE, every package.json, README).
- MUSICSHARE_FOSS=1 builds leave out the only closed-source code, Google's
  ML Kit / Play Services barcode scanner bundled by expo-camera; the scan
  screen then decodes small camera snapshots with jsQR instead.
- Expo modules build from source rather than from precompiled AARs, as
  F-Droid requires (that's also what makes the scanner switch take effect).
  Verified: a FOSS build contains no ML Kit or Play Services classes.
- Release builds default to the production server, and come out unsigned
  without our upload key (F-Droid signs with its own). versionCode 1.
- Store listing in fastlane/metadata/android, a draft fdroiddata recipe in
  fdroid/, and docs/FDROID.md with the submission steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
2026-10-06 15:26:59 -04:00

42 lines
1.9 KiB
JavaScript

// Signs release builds with the musicshare upload key when it's configured in
// ~/.gradle/gradle.properties (MUSICSHARE_UPLOAD_STORE_FILE, _STORE_PASSWORD,
// _KEY_ALIAS, _KEY_PASSWORD). Without it the release APK is left unsigned, which
// is what F-Droid expects (it signs with its own key). The key never lives in the repo.
const { withAppBuildGradle } = require('expo/config-plugins');
const MARKER = '// musicshare release signing';
const SIGNING_CONFIG = `
${MARKER}
release {
if (project.hasProperty('MUSICSHARE_UPLOAD_STORE_FILE')) {
storeFile file(MUSICSHARE_UPLOAD_STORE_FILE)
storePassword MUSICSHARE_UPLOAD_STORE_PASSWORD
keyAlias MUSICSHARE_UPLOAD_KEY_ALIAS
keyPassword MUSICSHARE_UPLOAD_KEY_PASSWORD
}
}`;
module.exports = function withReleaseSigning(config) {
return withAppBuildGradle(config, (cfg) => {
let gradle = cfg.modResults.contents;
if (gradle.includes(MARKER)) return cfg;
// Add a release signing config next to the debug one.
gradle = gradle.replace(/signingConfigs\s*\{/, (m) => `${m}${SIGNING_CONFIG}`);
// In the release build type, use it when the key is configured.
const release = gradle.indexOf('release {', gradle.indexOf('buildTypes {'));
if (release === -1) throw new Error('withReleaseSigning: no release build type in app/build.gradle');
const line = gradle.indexOf('signingConfig signingConfigs.debug', release);
if (line === -1) throw new Error('withReleaseSigning: release build type has no signingConfig line');
gradle =
gradle.slice(0, line) +
"signingConfig project.hasProperty('MUSICSHARE_UPLOAD_STORE_FILE') ? signingConfigs.release : null" +
gradle.slice(line + 'signingConfig signingConfigs.debug'.length);
cfg.modResults.contents = gradle;
return cfg;
});
};