Allow multiple files (#140)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-03-27 19:31:20 +01:00
committed by GitHub
parent 925acc7207
commit 1ebf61db85
10 changed files with 3750 additions and 152 deletions

View File

@@ -9,34 +9,37 @@ const osPlat: string = os.platform();
const osArch: string = os.arch();
export async function getUPX(version: string): Promise<string> {
core.startGroup(`Checking UPX ${version} release...`);
const release: github.GitHubRelease | null = await github.getRelease(version);
if (!release) {
throw new Error(`Cannot find UPX ${version} release`);
}
const semver: string = release.tag_name.replace(/^v/, '');
core.info(`UPX ${semver} found`);
core.endGroup();
core.info(`✅ UPX version found: ${semver}`);
const filename = util.format('%s.%s', getName(semver), osPlat == 'win32' ? 'zip' : 'tar.xz');
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', semver, filename);
core.info(`⬇️ Downloading ${downloadUrl}...`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`);
core.startGroup(`Downloading ${downloadUrl}...`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.info(`Downloaded to ${downloadPath}`);
core.info('📦 Extracting UPX...');
let extPath: string;
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
} else {
extPath = await tc.extractTar(downloadPath, undefined, 'x');
}
core.debug(`Extracted to ${extPath}`);
core.info(`Extracted to ${extPath}`);
const cachePath: string = await tc.cacheDir(extPath, 'ghaction-upx', semver);
core.debug(`Cached to ${cachePath}`);
const exePath: string = path.join(cachePath, getName(semver), osPlat == 'win32' ? 'upx.exe' : 'upx');
core.debug(`Exe path is ${exePath}`);
core.endGroup();
return exePath;
}