2020-01-17 01:36:42 -07:00
|
|
|
import * as os from 'os';
|
2021-03-27 12:31:20 -06:00
|
|
|
import * as context from './context';
|
2020-05-06 14:14:50 -06:00
|
|
|
import * as installer from './installer';
|
2020-01-08 14:26:34 -07:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as exec from '@actions/exec';
|
|
|
|
|
2020-05-07 04:11:19 -06:00
|
|
|
async function run(): Promise<void> {
|
2020-01-08 14:26:34 -07:00
|
|
|
try {
|
2020-01-17 01:36:42 -07:00
|
|
|
if (os.platform() == 'darwin') {
|
|
|
|
core.setFailed('Not supported on darwin platform');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-27 12:31:20 -06:00
|
|
|
const inputs: context.Inputs = await context.getInputs();
|
|
|
|
const upx = await installer.getUPX(inputs.version);
|
2020-01-08 14:26:34 -07:00
|
|
|
|
2022-04-24 12:30:15 -06:00
|
|
|
const files: string[] = context.resolvePaths(inputs.files);
|
2021-03-27 12:31:20 -06:00
|
|
|
if (files.length == 0) {
|
|
|
|
core.warning(`No files were found. Please check the 'files' input.`);
|
2020-05-06 14:14:50 -06:00
|
|
|
return;
|
2020-01-08 14:26:34 -07:00
|
|
|
}
|
|
|
|
|
2021-03-27 12:31:20 -06:00
|
|
|
await context.asyncForEach(files, async filepath => {
|
|
|
|
core.startGroup(`Compressing ${filepath}...`);
|
|
|
|
await exec.exec(`${upx} ${inputs.args} ${filepath}`);
|
|
|
|
core.endGroup();
|
|
|
|
});
|
2020-01-08 14:26:34 -07:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|