Skip to content

Commit

Permalink
Merge pull request #11 from Yakov5776/main
Browse files Browse the repository at this point in the history
Add `pageAlign` arg to workflow
  • Loading branch information
kevin-david authored Aug 5, 2024
2 parents 4585d16 + 78dde38 commit f184f27
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Then copy the contents of the `.txt` file to your GH secrets

**Optional:** True to run `zipalign` on the `.apk` to perform the operation, rather than just verify zipalign.

### `pageAlign`

**Optional:** Whether to use the `-p` flag with `zipalign`, which page-aligns uncompressed .so files.

## ENV: `BUILD_TOOLS_VERSION`

**Optional:** You can manually specify a version of build-tools to use. We use `32.0.0` by default.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: 'Actually zipalign the apk, rather than just verifying it'
required: false
default: 'false'
pageAlign:
description: 'Page-aligns uncompressed .so files'
required: false
default: 'true'
outputs:
signedReleaseFile:
description: 'The signed release APK or AAB file, if single'
Expand Down
3 changes: 2 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function run() {
const keyStorePassword = core.getInput('keyStorePassword', { required: true });
const keyPassword = core.getInput('keyPassword');
const zipAlign = core.getBooleanInput('zipAlign');
const pageAlign = core.getBooleanInput('pageAlign');
console.log(`Preparing to sign key @ ${releaseDir} with signing key`);
// 1. Find release files
const releaseFiles = io.findReleaseFiles(releaseDir);
Expand All @@ -69,7 +70,7 @@ function run() {
const releaseFilePath = path_1.default.join(releaseDir, releaseFile.name);
let signedReleaseFile = '';
if (releaseFile.name.endsWith('.apk')) {
signedReleaseFile = yield (0, signing_1.signApkFile)(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword, zipAlign);
signedReleaseFile = yield (0, signing_1.signApkFile)(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword, zipAlign, pageAlign);
}
else if (releaseFile.name.endsWith('.aab')) {
signedReleaseFile = yield (0, signing_1.signAabFile)(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword);
Expand Down
12 changes: 5 additions & 7 deletions lib/signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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, doZipAlign) {
function signApkFile(apkFile, signingKeyFile, alias, keyStorePassword, keyPassword, doZipAlign, usePageAlign) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
core.debug("Zipaligning APK file");
Expand All @@ -55,12 +55,10 @@ function signApkFile(apkFile, signingKeyFile, alias, keyStorePassword, keyPasswo
if (doZipAlign === true) {
const unAlignedApk = apkFile + ".unaligned";
fs.renameSync(apkFile, unAlignedApk);
yield exec.exec(`"${zipAlign}"`, [
'-v',
'4',
unAlignedApk,
apkFile
]);
const zipAlignArgs = ['-v', '4', unAlignedApk, apkFile];
if (usePageAlign)
zipAlignArgs.unshift('-p');
yield exec.exec(`"${zipAlign}"`, zipAlignArgs);
}
// Verify alignment
try {
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function run() {
const keyStorePassword = core.getInput('keyStorePassword', { required: true });
const keyPassword = core.getInput('keyPassword');
const zipAlign = core.getBooleanInput('zipAlign')
const pageAlign = core.getBooleanInput('pageAlign')

console.log(`Preparing to sign key @ ${releaseDir} with signing key`);

Expand All @@ -35,7 +36,7 @@ async function run() {
const releaseFilePath = path.join(releaseDir, releaseFile.name);
let signedReleaseFile = '';
if (releaseFile.name.endsWith('.apk')) {
signedReleaseFile = await signApkFile(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword, zipAlign);
signedReleaseFile = await signApkFile(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword, zipAlign, pageAlign);
} else if (releaseFile.name.endsWith('.aab')) {
signedReleaseFile = await signAabFile(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword);
} else {
Expand Down
12 changes: 5 additions & 7 deletions src/signing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export async function signApkFile(
alias: string,
keyStorePassword: string,
keyPassword?: string,
doZipAlign?: boolean
doZipAlign?: boolean,
usePageAlign?: boolean
): Promise<string> {

core.debug("Zipaligning APK file");
Expand All @@ -30,12 +31,9 @@ export async function signApkFile(
if (doZipAlign === true) {
const unAlignedApk = apkFile + ".unaligned";
fs.renameSync(apkFile, unAlignedApk);
await exec.exec(`"${zipAlign}"`, [
'-v',
'4',
unAlignedApk,
apkFile
]);
const zipAlignArgs = ['-v', '4', unAlignedApk, apkFile];
if (usePageAlign) zipAlignArgs.unshift('-p');
await exec.exec(`"${zipAlign}"`, zipAlignArgs);
}

// Verify alignment
Expand Down

0 comments on commit f184f27

Please sign in to comment.