Changed how the script sources the tools it needs

Added some more logging
This commit is contained in:
Drew Heavner
2019-11-08 15:46:49 -05:00
parent 71ce780cd2
commit bd300686fa
131 changed files with 48 additions and 8554 deletions
-28
View File
@@ -1,33 +1,5 @@
import * as tc from '@actions/tool-cache'
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import {Dirent} from "fs";
import fs from "fs";
import * as path from "path";
export async function downloadAndroidTools(toolsVersion: string = "4333796", buildToolsVersion: string = '29.0.2') {
const buildToolDir = tc.find('build-tools', buildToolsVersion);
if (buildToolDir.length == 0) {
const androidToolPath = await tc.downloadTool(`https://dl.google.com/android/repository/sdk-tools-linux-${toolsVersion}.zip`);
const androidToolExtractedFolder = await tc.extractZip(androidToolPath, 'android-sdk');
const cachedPath = await tc.cacheDir(androidToolExtractedFolder, 'android-sdk', toolsVersion);
core.addPath(cachedPath);
core.addPath(path.join(cachedPath, 'bin'));
// Install the platform tools
exec.exec('yes | sdkmanager --licenses');
exec.exec('yes | sdkmanager', [
`\"build-tools;${buildToolsVersion}\"`
]);
// Add our new build tools to the exec path
const cachedBuildTools = await tc.cacheDir(path.join(cachedPath, `build-tools/${buildToolsVersion}`), "build-tools", buildToolsVersion);
core.addPath(cachedBuildTools)
} else {
core.addPath(buildToolDir)
}
}
export function findReleaseFile(releaseDir: string): Dirent | undefined {
const releaseFiles = fs.readdirSync(releaseDir, {withFileTypes: true})
+3 -3
View File
@@ -19,9 +19,6 @@ async function run() {
if (releaseFile !== undefined) {
core.debug(`Found release to sign: ${releaseFile.name}`);
// 2. Install Android tools
await io.downloadAndroidTools();
// 3. Now that we have a release file, decode and save the signing key
const signingKey = path.join(releaseDir, 'signingKey.jks');
fs.writeFileSync(signingKey, signingKeyBase64, 'base64');
@@ -38,6 +35,9 @@ async function run() {
core.setFailed('No valid release file to sign.');
}
console.log('Release signed!');
core.debug('Release signed! Setting outputs');
core.exportVariable("SIGNED_RELEASE_FILE", signedReleaseFile);
core.setOutput('signedReleaseFile', signedReleaseFile);
} else {
+15 -3
View File
@@ -1,5 +1,6 @@
import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as io from '@actions/io';
export async function signApkFile(
apkFile: string,
@@ -11,9 +12,13 @@ export async function signApkFile(
core.debug("Zipaligning APK file");
// Find zipalign executable
const zipAlignPath = await io.which('zipalign', true);
core.debug(`Found 'zipalign' @ ${zipAlignPath}`);
// Align the apk file
const alignedApkFile = apkFile.replace('.apk', '-aligned.apk');
await exec.exec('zipalign', [
await exec.exec(`"${zipAlignPath}"`, [
'-v', '-p 4',
apkFile,
alignedApkFile
@@ -21,9 +26,13 @@ export async function signApkFile(
core.debug("Signing APK file");
// find apksigner path
const apkSignerPath = await io.which('apksigner', true);
core.debug(`Found 'apksigner' @ ${apkSignerPath}`);
// 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', [
await exec.exec(`"${apkSignerPath}"`, [
'sign',
'--ks', signingKeyFile,
'--out', signedApkFile,
@@ -41,7 +50,10 @@ export async function signAabFile(
keyPassword: string
): Promise<string> {
core.debug("Signing AAB file");
await exec.exec(`jarsigner`, [
const jarSignerPath = await io.which('jarsigner', true);
core.debug(`Found 'jarsigner' @ ${jarSignerPath}`);
await exec.exec(`"${jarSignerPath}"`, [
'-keystore', signingKeyFile,
'-storepass', keyStorePassword,
'-keypass', keyPassword,
-10
View File
@@ -1,10 +0,0 @@
export function wait(milliseconds: number) {
return new Promise((resolve) => {
if (isNaN(milliseconds)) {
throw new Error('milleseconds not a number');
}
setTimeout(() => resolve("done!"), milliseconds)
});
}