Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(export): an Android release key may be named under the home directory

esenginef3457520c74e
diff --git a/pipeline/src/export/projectExportOptions.ts b/pipeline/src/export/projectExportOptions.ts
index f56212d63..dfb27c9d0 100644
--- a/pipeline/src/export/projectExportOptions.ts
+++ b/pipeline/src/export/projectExportOptions.ts
@@ -11,6 +11,7 @@
* only what the person chose for this build on top.
*/
import path from 'node:path';
+import { homedir } from 'node:os';
import type { ExportGameOptions } from './exportGame';
import { readReleaseKey } from './rpk';
import { signingKeyFromPem, type SigningKey } from '../../../build-tools/utils/androidKeystore.js';
@@ -128,11 +129,17 @@ function androidReleaseKey(
): SigningKey {
try {
return signingKeyFromPem({
- key: path.resolve(root, paths.privateKey),
- cert: path.resolve(root, paths.certificate),
+ key: keyPath(root, paths.privateKey),
+ cert: keyPath(root, paths.certificate),
...(passphrase ? { passphrase } : {}),
});
} catch (e) {
throw new Error(`the Android release key could not be read (${paths.privateKey}, ${paths.certificate}): ${(e as Error).message}`);
}
}
+
+/** A key path as the settings page invites it: relative to the project, absolute,
+ * or under the home directory (`~/…`). */
+function keyPath(root: string, file: string): string {
+ return /^~[/\\]/.test(file) ? path.join(homedir(), file.slice(2)) : path.resolve(root, file);
+}
diff --git a/pipeline/tests/project-export-options.test.ts b/pipeline/tests/project-export-options.test.ts
index 238e50c6e..c34c31a1e 100644
--- a/pipeline/tests/project-export-options.test.ts
+++ b/pipeline/tests/project-export-options.test.ts
@@ -6,7 +6,7 @@
*/
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
-import { tmpdir } from 'node:os';
+import { tmpdir, homedir } from 'node:os';
import path from 'node:path';
import { parseManifest } from '../src/project/format';
import { projectExportOptions } from '../src/export/projectExportOptions';
@@ -188,6 +188,15 @@ describe('an Android release key', () => {
}
});
+ it('may live under the home directory, written with ~', async () => {
+ const m = parseManifest({
+ formatVersion: '1', name: 'p',
+ packaging: { platforms: { android: { releaseKey: { privateKey: '~/no-such-estella-key.pem', certificate: '~/c.pem' } } } },
+ });
+ const o = await projectExportOptions(root, m, 'android');
+ expect(() => (o.androidKey as () => unknown)()).toThrow(new RegExp(homedir().replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')));
+ });
+
it('that cannot be read says so when it is needed, and not before', async () => {
const m = parseManifest({
formatVersion: '1', name: 'p',
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 2ef89a90d..fcbdb7212 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -1164,4 +1164,6 @@ export const NOTED = {
{ note: '**Android release signing.** A Shipping APK (and App Bundle) is signed with the release key the project names under Project Settings → Android → Signing — two PEM paths, the passphrase kept in this machine\'s keychain (the command line reads `ESTELLA_ANDROID_KEY_PASSPHRASE`); Development builds keep the development key. A Shipping build without one says it will be refused by Google Play.' },
'feat(settings): Android release signing is set in Project Settings':
{ note: '**Android release signing.** A Shipping APK (and App Bundle) is signed with the release key the project names under Project Settings → Android → Signing — two PEM paths, the passphrase kept in this machine\'s keychain (the command line reads `ESTELLA_ANDROID_KEY_PASSPHRASE`); Development builds keep the development key. A Shipping build without one says it will be refused by Google Play.' },
+ 'fix(export): an Android release key may be named under the home directory':
+ { note: '**Android release signing.** A Shipping APK (and App Bundle) is signed with the release key the project names under Project Settings → Android → Signing — two PEM paths, the passphrase kept in this machine\'s keychain (the command line reads `ESTELLA_ANDROID_KEY_PASSPHRASE`); Development builds keep the development key. A Shipping build without one says it will be refused by Google Play.' },
};