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
-43
View File
@@ -1,52 +1,9 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tc = __importStar(require("@actions/tool-cache"));
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const fs_1 = __importDefault(require("fs"));
const path = __importStar(require("path"));
function downloadAndroidTools(toolsVersion = "4333796", buildToolsVersion = '29.0.2') {
return __awaiter(this, void 0, void 0, function* () {
const buildToolDir = tc.find('build-tools', buildToolsVersion);
if (buildToolDir.length === 0) {
const androidToolPath = yield tc.downloadTool(`https://dl.google.com/android/repository/sdk-tools-linux-${toolsVersion}.zip`);
const androidToolExtractedFolder = yield tc.extractZip(androidToolPath, 'android-sdk');
const cachedPath = yield 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 = yield tc.cacheDir(path.join(cachedPath, `build-tools/${buildToolsVersion}`), "build-tools", buildToolsVersion);
core.addPath(cachedBuildTools);
}
else {
core.addPath(buildToolDir);
}
});
}
exports.downloadAndroidTools = downloadAndroidTools;
function findReleaseFile(releaseDir) {
const releaseFiles = fs_1.default.readdirSync(releaseDir, { withFileTypes: true })
.filter(item => !item.isDirectory())
+2 -2
View File
@@ -36,8 +36,6 @@ function run() {
const releaseFile = io.findReleaseFile(releaseDir);
if (releaseFile !== undefined) {
core.debug(`Found release to sign: ${releaseFile.name}`);
// 2. Install Android tools
yield io.downloadAndroidTools();
// 3. Now that we have a release file, decode and save the signing key
const signingKey = path_1.default.join(releaseDir, 'signingKey.jks');
fs_1.default.writeFileSync(signingKey, signingKeyBase64, 'base64');
@@ -54,6 +52,8 @@ function run() {
core.error('No valid release file to sign, abort.');
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);
}
+12 -3
View File
@@ -17,20 +17,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec"));
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
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}`);
// Align the apk file
const alignedApkFile = apkFile.replace('.apk', '-aligned.apk');
yield exec.exec('zipalign', [
yield exec.exec(`"${zipAlignPath}"`, [
'-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}`);
// 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', [
yield exec.exec(`"${apkSignerPath}"`, [
'sign',
'--ks', signingKeyFile,
'--out', signedApkFile,
@@ -43,7 +50,9 @@ exports.signApkFile = signApkFile;
function signAabFile(aabFile, signingKeyFile, alias, keyStorePassword, keyPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.debug("Signing AAB file");
yield exec.exec(`jarsigner`, [
const jarSignerPath = yield io.which('jarsigner', true);
core.debug(`Found 'jarsigner' @ ${jarSignerPath}`);
yield exec.exec(`"${jarSignerPath}"`, [
'-keystore', signingKeyFile,
'-storepass', keyStorePassword,
'-keypass', keyPassword,