mirror of
https://github.com/r0adkll/sign-android-release
synced 2026-10-01 09:01:36 +00:00
Added set to download/install/cache the android sdk tools for signing release builds
This commit is contained in:
138 files changed
+9239
-27
No files matched your search
+30
-3
@@ -1,7 +1,33 @@
|
||||
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";
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
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})
|
||||
@@ -11,4 +37,5 @@ export function findReleaseFile(releaseDir: string): Dirent | undefined {
|
||||
if (releaseFiles.length > 0) {
|
||||
return releaseFiles[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -19,11 +19,14 @@ async function run() {
|
||||
if (releaseFile !== undefined) {
|
||||
core.debug(`Found release to sign: ${releaseFile.name}`);
|
||||
|
||||
// 2. Now that we have a release file, decode and save the signing key
|
||||
// 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');
|
||||
|
||||
// 3. Now zipalign the release file
|
||||
// 4. Now zipalign the release file
|
||||
const releaseFilePath = path.join(releaseDir, releaseFile.name);
|
||||
let signedReleaseFile = '';
|
||||
if (releaseFile.name.endsWith('.apk')) {
|
||||
|
||||
Reference in new issue
Block a user