Fixing the android path tooling

This commit is contained in:
Drew Heavner
2019-11-08 17:12:56 -05:00
parent bd300686fa
commit cc14b0e221
3 changed files with 29 additions and 12 deletions
+14 -6
View File
@@ -18,26 +18,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec"));
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
function signApkFile(apkFile, signingKeyFile, alias, keyStorePassword, keyPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.debug("Zipaligning APK file");
// Find zipalign executable
const zipAlignPath = yield io.which('zipalign', true);
core.debug(`Found 'zipalign' @ ${zipAlignPath}`);
const buildToolsVersion = process.env.BUILD_TOOLS_VERSION || '29.0.2';
const androidHome = process.env.ANDROID_HOME;
const buildTools = path.join(androidHome, `build-tools/${buildToolsVersion}`);
if (!fs.existsSync(buildTools)) {
core.error(`Couldnt find the Android build tools @ ${buildTools}`);
}
const zipAlign = path.join(buildTools, 'zipalign');
core.debug(`Found 'zipalign' @ ${zipAlign}`);
// Align the apk file
const alignedApkFile = apkFile.replace('.apk', '-aligned.apk');
yield exec.exec(`"${zipAlignPath}"`, [
yield exec.exec(`"${zipAlign}"`, [
'-v', '-p 4',
apkFile,
alignedApkFile
]);
core.debug("Signing APK file");
// find apksigner path
const apkSignerPath = yield io.which('apksigner', true);
core.debug(`Found 'apksigner' @ ${apkSignerPath}`);
const apkSigner = path.join(buildTools, 'apksigner');
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(`"${apkSignerPath}"`, [
yield exec.exec(`"${apkSigner}"`, [
'sign',
'--ks', signingKeyFile,
'--out', signedApkFile,
+15 -6
View File
@@ -1,6 +1,8 @@
import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as path from "path";
import * as fs from "fs";
export async function signApkFile(
apkFile: string,
@@ -13,12 +15,19 @@ export async function signApkFile(
core.debug("Zipaligning APK file");
// Find zipalign executable
const zipAlignPath = await io.which('zipalign', true);
core.debug(`Found 'zipalign' @ ${zipAlignPath}`);
const buildToolsVersion = process.env.BUILD_TOOLS_VERSION || '29.0.2';
const androidHome = process.env.ANDROID_HOME;
const buildTools = path.join(androidHome!, `build-tools/${buildToolsVersion}`);
if (!fs.existsSync(buildTools)) {
core.error(`Couldnt find the Android build tools @ ${buildTools}`)
}
const zipAlign = path.join(buildTools, 'zipalign');
core.debug(`Found 'zipalign' @ ${zipAlign}`);
// Align the apk file
const alignedApkFile = apkFile.replace('.apk', '-aligned.apk');
await exec.exec(`"${zipAlignPath}"`, [
await exec.exec(`"${zipAlign}"`, [
'-v', '-p 4',
apkFile,
alignedApkFile
@@ -27,12 +36,12 @@ export async function signApkFile(
core.debug("Signing APK file");
// find apksigner path
const apkSignerPath = await io.which('apksigner', true);
core.debug(`Found 'apksigner' @ ${apkSignerPath}`);
const apkSigner = path.join(buildTools, 'apksigner');
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');
await exec.exec(`"${apkSignerPath}"`, [
await exec.exec(`"${apkSigner}"`, [
'sign',
'--ks', signingKeyFile,
'--out', signedApkFile,
Regular → Executable
View File