55 lines
2.3 KiB
TypeScript
55 lines
2.3 KiB
TypeScript
/**
|
|
* What the release asks custos-sign to do with the Android APK (fabrica-release.md F4). Kept
|
|
* apart from the script that runs it so the arguments can be tested without Custos.
|
|
*
|
|
* The key `rosea-android` lives in Custos only; custos-sign holds no key material either. Its
|
|
* scope is exactly `mnovak/Rosea`, the release pipeline, a tag (Custos makes the key on the first
|
|
* release, behind Mark's first-signature card).
|
|
*/
|
|
export const APK_KEY = 'rosea-android';
|
|
export const REPO = 'mnovak/Rosea';
|
|
|
|
/** Where Gradle leaves the release APK of `tauri android build --apk --target aarch64`, from src-tauri. */
|
|
export const UNSIGNED_APK = 'gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk';
|
|
|
|
/** The published APK's name: the app, the version, the one ABI it is built for. */
|
|
export const signedApkName = (version: string): string => `rosea-domi-${version}-arm64.apk`;
|
|
|
|
export interface SignRequest {
|
|
readonly version: string;
|
|
readonly commit: string;
|
|
readonly unsigned: string;
|
|
readonly out: string;
|
|
}
|
|
|
|
/** The arguments of `custos-sign apk`, or the reason they cannot be made. */
|
|
export function signArgs(r: SignRequest): string[] {
|
|
if (!/^\d+\.\d+\.\d+$/.test(r.version)) throw new Error(`not a version: ${r.version}`);
|
|
if (!/^[0-9a-f]{40}$/.test(r.commit)) throw new Error(`not a commit: ${r.commit}`);
|
|
return [
|
|
'apk', r.unsigned,
|
|
'--out', r.out,
|
|
'--key', APK_KEY,
|
|
'--repo', REPO,
|
|
'--pipeline', 'release',
|
|
'--commit', r.commit,
|
|
'--trigger', 'tag',
|
|
'--run', `rosea-v${r.version}`,
|
|
'--version', r.version,
|
|
'--step', 'apk'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Which custos-sign to run. `CUSTOS_SIGN_EXE` names it; when it names a file that is not there,
|
|
* the release refuses rather than run another one from PATH. `CUSTOS_PIPE` is refused: a signed
|
|
* run must reach Mark's Custos, never a test instance whose key is nobody's.
|
|
*/
|
|
export function custosSign(env: Readonly<Record<string, string | undefined>>, exists: (p: string) => boolean): string {
|
|
if (env['CUSTOS_PIPE']) throw new Error('CUSTOS_PIPE is set: the APK would be signed by another Custos than Mark\'s');
|
|
const named = env['CUSTOS_SIGN_EXE'];
|
|
if (named === undefined || named === '') return 'custos-sign.exe';
|
|
if (!exists(named)) throw new Error(`CUSTOS_SIGN_EXE names ${named}, which is not there`);
|
|
return named;
|
|
}
|