Merge pull request #3 from kceb/master

feat: Make key password optional
This commit is contained in:
Drew Heavner
2020-04-01 13:58:04 -04:00
committed by GitHub
4 changed files with 39 additions and 25 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ Then copy the contents of the `.txt` file to your GH secrets
### `keyPassword`
**Required:** The private key password for your signing keystore
**Optional:** The private key password for your signing keystore
## Outputs
+1 -1
View File
@@ -19,7 +19,7 @@ inputs:
required: true
keyPassword:
description: 'The password for the key'
required: true
required: false
outputs:
signedReleaseFile:
description: 'The signed release APK or AAB file'
+15 -10
View File
@@ -45,15 +45,18 @@ function signApkFile(apkFile, signingKeyFile, alias, keyStorePassword, keyPasswo
core.debug(`Found 'apksigner' @ ${apkSigner}`);
// apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
const signedApkFile = apkFile.replace('.apk', '-signed.apk');
yield exec.exec(`"${apkSigner}"`, [
const args = [
'sign',
'--ks', signingKeyFile,
'--ks-key-alias', alias,
'--ks-pass', `pass:${keyStorePassword}`,
'--key-pass', `pass:${keyPassword}`,
'--out', signedApkFile,
alignedApkFile
]);
'--out', signedApkFile
];
if (keyPassword) {
args.push('--key-pass', `pass:${keyPassword}`);
}
args.push(alignedApkFile);
yield exec.exec(`"${apkSigner}"`, args);
// Verify
core.debug("Verifying Signed APK");
yield exec.exec(`"${apkSigner}"`, [
@@ -69,13 +72,15 @@ function signAabFile(aabFile, signingKeyFile, alias, keyStorePassword, keyPasswo
core.debug("Signing AAB file");
const jarSignerPath = yield io.which('jarsigner', true);
core.debug(`Found 'jarsigner' @ ${jarSignerPath}`);
yield exec.exec(`"${jarSignerPath}"`, [
const args = [
'-keystore', signingKeyFile,
'-storepass', keyStorePassword,
'-keypass', keyPassword,
aabFile,
alias
]);
];
if (keyPassword) {
args.push('-keypass', keyPassword);
}
args.push(aabFile, alias);
yield exec.exec(`"${jarSignerPath}"`, args);
return aabFile;
});
}
+22 -13
View File
@@ -9,7 +9,7 @@ export async function signApkFile(
signingKeyFile: string,
alias: string,
keyStorePassword: string,
keyPassword: string
keyPassword?: string
): Promise<string> {
core.debug("Zipaligning APK file");
@@ -41,15 +41,20 @@ export async function signApkFile(
// apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
const signedApkFile = apkFile.replace('.apk', '-signed.apk');
await exec.exec(`"${apkSigner}"`, [
const args = [
'sign',
'--ks', signingKeyFile,
'--ks-key-alias', alias,
'--ks-pass', `pass:${keyStorePassword}`,
'--key-pass', `pass:${keyPassword}`,
'--out', signedApkFile,
alignedApkFile
]);
'--out', signedApkFile
];
if (keyPassword) {
args.push('--key-pass', `pass:${keyPassword}`);
}
args.push(alignedApkFile);
await exec.exec(`"${apkSigner}"`, args);
// Verify
core.debug("Verifying Signed APK");
@@ -66,19 +71,23 @@ export async function signAabFile(
signingKeyFile: string,
alias: string,
keyStorePassword: string,
keyPassword: string
keyPassword?: string,
): Promise<string> {
core.debug("Signing AAB file");
const jarSignerPath = await io.which('jarsigner', true);
core.debug(`Found 'jarsigner' @ ${jarSignerPath}`);
await exec.exec(`"${jarSignerPath}"`, [
const args = [
'-keystore', signingKeyFile,
'-storepass', keyStorePassword,
'-keypass', keyPassword,
aabFile,
alias
]);
];
if (keyPassword) {
args.push('-keypass', keyPassword);
}
args.push(aabFile, alias);
await exec.exec(`"${jarSignerPath}"`, args);
return aabFile
}