mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2026-04-14 10:32:59 -06:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce8d5a88dc | ||
|
|
798798f112 | ||
|
|
93bb242097 | ||
|
|
6395a3aa2f | ||
|
|
232b78f307 | ||
|
|
3a9e38d798 | ||
|
|
9e29288823 | ||
|
|
5fb44a383c | ||
|
|
a77f62c7b2 | ||
|
|
4016520b1a | ||
|
|
43e96ba7c7 | ||
|
|
84be82804b | ||
|
|
1d77879094 | ||
|
|
a49a31ec57 | ||
|
|
4e207aef79 | ||
|
|
13cfa21ed2 | ||
|
|
cf7c59718e | ||
|
|
3bb5082440 | ||
|
|
2cca363863 | ||
|
|
74f8aad623 | ||
|
|
179c8d1999 | ||
|
|
07776888af | ||
|
|
8109f2b0b1 | ||
|
|
ff1f7b6f02 | ||
|
|
70b04fa8cc | ||
|
|
a29487bfda | ||
|
|
ccf18cffd8 | ||
|
|
85281740bf | ||
|
|
05a76fdd78 | ||
|
|
8028365153 | ||
|
|
b72f85285f | ||
|
|
7030d1d220 | ||
|
|
a6aa6e0fc3 | ||
|
|
d6d7f82212 | ||
|
|
70f3e1534a | ||
|
|
2840f8db19 |
33
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
33
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
### Behaviour
|
||||
|
||||
#### Steps to reproduce this issue
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
#### Expected behaviour
|
||||
|
||||
> Tell me what should happen
|
||||
|
||||
#### Actual behaviour
|
||||
|
||||
> Tell me what happens instead
|
||||
|
||||
### Configuration
|
||||
|
||||
* Repository URL (if public):
|
||||
* Build URL (if public):
|
||||
|
||||
```yml
|
||||
# paste your YAML workflow file here and remove sensitive data
|
||||
```
|
||||
|
||||
### Logs
|
||||
|
||||
> Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
|
||||
29
.github/SUPPORT.md
vendored
Normal file
29
.github/SUPPORT.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Support [](https://isitmaintained.com/project/crazy-max/ghaction-upx)
|
||||
|
||||
## Reporting an issue
|
||||
|
||||
Please do a search in [open issues](https://github.com/crazy-max/ghaction-upx/issues?utf8=%E2%9C%93&q=) to see if the issue or feature request has already been filed.
|
||||
|
||||
If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment.
|
||||
|
||||
:+1: - upvote
|
||||
|
||||
:-1: - downvote
|
||||
|
||||
If you cannot find an existing issue that describes your bug or feature, submit an issue using the guidelines below.
|
||||
|
||||
## Writing good bug reports and feature requests
|
||||
|
||||
File a single issue per problem and feature request.
|
||||
|
||||
* Do not enumerate multiple bugs or feature requests in the same issue.
|
||||
* Do not add your issue as a comment to an existing issue unless it's for the identical input. Many issues look similar, but have different causes.
|
||||
|
||||
The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix.
|
||||
|
||||
You are now ready to [create a new issue](https://github.com/crazy-max/ghaction-upx/issues/new/choose)!
|
||||
|
||||
## Closure policy
|
||||
|
||||
* Issues that don't have the information requested above (when applicable) will be closed immediately and the poster directed to the support guidelines.
|
||||
* Issues that go a week without a response from original poster are subject to closure at my discretion.
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Download file
|
||||
id: download
|
||||
|
||||
4
.github/workflows/labels.yml
vendored
4
.github/workflows/labels.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
# https://github.com/crazy-max/ghaction-github-labeler
|
||||
name: Run Labeler
|
||||
if: success()
|
||||
uses: crazy-max/ghaction-github-labeler@v1
|
||||
uses: crazy-max/ghaction-github-labeler@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
@@ -13,7 +13,11 @@ jobs:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
# https://github.com/actions/setup-node
|
||||
name: Set up Node
|
||||
uses: actions/setup-node@v1
|
||||
-
|
||||
name: Setup TS
|
||||
run: npm install tslint typescript -g
|
||||
|
||||
6
.github/workflows/master.yml
vendored
6
.github/workflows/master.yml
vendored
@@ -12,11 +12,7 @@ jobs:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
-
|
||||
# https://github.com/actions/checkout/issues/6
|
||||
name: Fix detached HEAD
|
||||
run: git checkout ${GITHUB_REF#refs/heads/}
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Build
|
||||
run: |
|
||||
|
||||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Build
|
||||
run: |
|
||||
@@ -36,3 +36,11 @@ jobs:
|
||||
-
|
||||
name: Test
|
||||
run: npm run test
|
||||
-
|
||||
# https://github.com/codecov/codecov-action
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
if: success()
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage/clover.xml
|
||||
|
||||
20
CHANGELOG.md
Normal file
20
CHANGELOG.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Changelog
|
||||
|
||||
## 1.3.0 (2020/05/06)
|
||||
|
||||
* Use native tools
|
||||
* Add Codecov
|
||||
* Update deps
|
||||
|
||||
## 1.2.0 (2020/04/09)
|
||||
|
||||
* Use ncc and clean workflows
|
||||
* Update deps
|
||||
|
||||
## 1.1.0 (2020/01/17)
|
||||
|
||||
* Update deps
|
||||
|
||||
## 1.0.0 (2020/01/17)
|
||||
|
||||
* Initial version
|
||||
@@ -1,7 +1,7 @@
|
||||
[](https://github.com/crazy-max/ghaction-upx/releases/latest)
|
||||
[](https://github.com/marketplace/actions/upx-github-action)
|
||||
[](https://github.com/crazy-max/ghaction-upx/actions?workflow=release)
|
||||
[](https://github.com/crazy-max/ghaction-upx/actions?workflow=test)
|
||||
[](https://github.com/crazy-max/ghaction-upx/actions?workflow=test)
|
||||
[](https://codecov.io/gh/crazy-max/ghaction-upx)
|
||||
[](https://github.com/sponsors/crazy-max)
|
||||
[](https://www.paypal.me/crazyws)
|
||||
|
||||
@@ -11,8 +11,6 @@ GitHub Action for [UPX](https://github.com/upx/upx), the Ultimate Packer for eXe
|
||||
|
||||
## Usage
|
||||
|
||||
Below is a simple snippet to use this action. A [live example](https://github.com/crazy-max/ghaction-upx/actions) is also available for this repository.
|
||||
|
||||
```yaml
|
||||
name: upx
|
||||
|
||||
@@ -26,7 +24,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Run UPX
|
||||
uses: crazy-max/ghaction-upx@v1
|
||||
|
||||
9
__tests__/github.test.ts
Normal file
9
__tests__/github.test.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as github from '../src/github';
|
||||
|
||||
describe('github', () => {
|
||||
it('returns 3.96 GitHub release', async () => {
|
||||
const release = await github.getRelease('3.96');
|
||||
expect(release).not.toBeNull();
|
||||
expect(release?.tag_name).toEqual('v3.96');
|
||||
});
|
||||
});
|
||||
24171
dist/index.js
generated
vendored
24171
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
83
lib/installer.js
generated
83
lib/installer.js
generated
@@ -1,83 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
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) : adopt(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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const download = __importStar(require("download"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const util = __importStar(require("util"));
|
||||
const restm = __importStar(require("typed-rest-client/RestClient"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
let osPlat = os.platform();
|
||||
let osArch = os.arch();
|
||||
function getUPX(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const selected = yield determineVersion(version);
|
||||
if (selected) {
|
||||
version = selected;
|
||||
}
|
||||
core.info(`✅ UPX version found: ${version}`);
|
||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'upx-'));
|
||||
const fileName = getFileName(version);
|
||||
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', version, fileName);
|
||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||
yield download.default(downloadUrl, tmpdir, { filename: fileName });
|
||||
core.info('📦 Extracting UPX...');
|
||||
let extPath = tmpdir;
|
||||
if (osPlat == 'win32') {
|
||||
extPath = yield tc.extractZip(`${tmpdir}/${fileName}`);
|
||||
}
|
||||
else {
|
||||
extPath = yield tc.extractTar(`${tmpdir}/${fileName}`, undefined, 'x');
|
||||
}
|
||||
return path.join(extPath, getFileNameWithoutExt(version), osPlat == 'win32' ? 'upx.exe' : 'upx');
|
||||
});
|
||||
}
|
||||
exports.getUPX = getUPX;
|
||||
function getFileName(version) {
|
||||
const ext = osPlat == 'win32' ? 'zip' : 'tar.xz';
|
||||
return util.format('%s.%s', getFileNameWithoutExt(version), ext);
|
||||
}
|
||||
function getFileNameWithoutExt(version) {
|
||||
let platform = '';
|
||||
if (osPlat == 'win32') {
|
||||
platform = osArch == 'x64' ? 'win64' : 'win32';
|
||||
}
|
||||
else if (osPlat == 'linux') {
|
||||
platform = osArch == 'x64' ? 'amd64_linux' : 'i386_linux';
|
||||
}
|
||||
return util.format('upx-%s-%s', version, platform);
|
||||
}
|
||||
function determineVersion(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let rest = new restm.RestClient('ghaction-upx', 'https://github.com', undefined, {
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
});
|
||||
if (version !== 'latest') {
|
||||
version = `v${version}`;
|
||||
}
|
||||
let res = yield rest.get(`/upx/upx/releases/${version}`);
|
||||
if (res.statusCode != 200 || res.result === null) {
|
||||
throw new Error(`Cannot find UPX ${version} release (http ${res.statusCode})`);
|
||||
}
|
||||
return res.result.tag_name.replace(/^v/, '');
|
||||
});
|
||||
}
|
||||
49
lib/main.js
generated
49
lib/main.js
generated
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
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) : adopt(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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const installer = __importStar(require("./installer"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
function run(silent) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (os.platform() == 'darwin') {
|
||||
core.setFailed('Not supported on darwin platform');
|
||||
return;
|
||||
}
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const file = core.getInput('file', { required: true });
|
||||
const args = core.getInput('args');
|
||||
const upx = yield installer.getUPX(version);
|
||||
if (!fs.existsSync(file)) {
|
||||
core.setFailed(`⛔ File to compress not found: ${file}`);
|
||||
}
|
||||
console.log('🏃 Running UPX...');
|
||||
yield exec.exec(`${upx} ${args} ${file}`, undefined, {
|
||||
silent: silent
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.run = run;
|
||||
run();
|
||||
5344
package-lock.json
generated
5344
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@@ -2,12 +2,9 @@
|
||||
"name": "upx-github-action",
|
||||
"description": "GitHub Action for UPX, the Ultimate Packer for eXecutables",
|
||||
"main": "lib/main.js",
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc && ncc build",
|
||||
"test": "jest",
|
||||
"test": "jest --coverage",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"pre-checkin": "npm run format && npm run build"
|
||||
@@ -23,22 +20,20 @@
|
||||
"author": "CrazyMax",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.3",
|
||||
"@actions/exec": "^1.0.3",
|
||||
"@actions/tool-cache": "^1.3.3",
|
||||
"download": "^8.0.0",
|
||||
"typed-rest-client": "^1.7.3"
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/tool-cache": "^1.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^13.11.0",
|
||||
"@types/download": "^6.2.4",
|
||||
"@types/node": "^13.13.4",
|
||||
"@zeit/ncc": "^0.22.1",
|
||||
"jest": "^25.2.7",
|
||||
"jest-circus": "^25.2.7",
|
||||
"jest-runtime": "^25.2.7",
|
||||
"prettier": "^2.0.4",
|
||||
"ts-jest": "^25.3.1",
|
||||
"jest": "^25.5.0",
|
||||
"jest-circus": "^25.5.0",
|
||||
"jest-runtime": "^25.5.0",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^25.4.0",
|
||||
"typescript": "^3.8.3",
|
||||
"typescript-formatter": "^7.2.2"
|
||||
}
|
||||
|
||||
12
src/github.ts
Normal file
12
src/github.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as httpm from '@actions/http-client';
|
||||
|
||||
export interface GitHubRelease {
|
||||
id: number;
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
export const getRelease = async (version: string): Promise<GitHubRelease | null> => {
|
||||
const url: string = `https://github.com/upx/upx/releases/${version !== 'latest' ? `v${version}` : version}`;
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('ghaction-upx');
|
||||
return (await http.getJson<GitHubRelease>(url)).result;
|
||||
};
|
||||
@@ -1,9 +1,7 @@
|
||||
import * as download from 'download';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
import * as restm from 'typed-rest-client/RestClient';
|
||||
import * as github from './github';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
@@ -11,36 +9,37 @@ let osPlat: string = os.platform();
|
||||
let osArch: string = os.arch();
|
||||
|
||||
export async function getUPX(version: string): Promise<string> {
|
||||
const selected = await determineVersion(version);
|
||||
if (selected) {
|
||||
version = selected;
|
||||
const release: github.GitHubRelease | null = await github.getRelease(version);
|
||||
if (!release) {
|
||||
throw new Error(`Cannot find UPX ${version} release`);
|
||||
}
|
||||
|
||||
core.info(`✅ UPX version found: ${version}`);
|
||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'upx-'));
|
||||
const fileName = getFileName(version);
|
||||
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', version, fileName);
|
||||
const semver: string = release.tag_name.replace(/^v/, '');
|
||||
core.debug(`Semver is ${semver}`);
|
||||
|
||||
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}...`);
|
||||
await download.default(downloadUrl, tmpdir, {filename: fileName});
|
||||
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
||||
core.debug(`Downloaded to ${downloadPath}`);
|
||||
|
||||
core.info('📦 Extracting UPX...');
|
||||
let extPath: string = tmpdir;
|
||||
if (osPlat == 'win32') {
|
||||
extPath = await tc.extractZip(`${tmpdir}/${fileName}`);
|
||||
} else {
|
||||
extPath = await tc.extractTar(`${tmpdir}/${fileName}`, undefined, 'x');
|
||||
}
|
||||
const extPath: string =
|
||||
osPlat == 'win32' ? await tc.extractZip(downloadPath) : await tc.extractTar(downloadPath, undefined, 'x');
|
||||
core.debug(`Extracted to ${extPath}`);
|
||||
|
||||
return path.join(extPath, getFileNameWithoutExt(version), osPlat == 'win32' ? 'upx.exe' : 'upx');
|
||||
const cachePath: string = await tc.cacheDir(extPath, 'ghaction-upx', version);
|
||||
core.debug(`Cached to ${cachePath}`);
|
||||
|
||||
const exePath: string = path.join(cachePath, getName(semver), osPlat == 'win32' ? 'upx.exe' : 'upx');
|
||||
core.debug(`Exe path is ${exePath}`);
|
||||
|
||||
return exePath;
|
||||
}
|
||||
|
||||
function getFileName(version: string): string {
|
||||
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.xz';
|
||||
return util.format('%s.%s', getFileNameWithoutExt(version), ext);
|
||||
}
|
||||
|
||||
function getFileNameWithoutExt(version: string): string {
|
||||
function getName(version: string): string {
|
||||
let platform: string = '';
|
||||
if (osPlat == 'win32') {
|
||||
platform = osArch == 'x64' ? 'win64' : 'win32';
|
||||
@@ -49,26 +48,3 @@ function getFileNameWithoutExt(version: string): string {
|
||||
}
|
||||
return util.format('upx-%s-%s', version, platform);
|
||||
}
|
||||
|
||||
interface GitHubRelease {
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
async function determineVersion(version: string): Promise<string> {
|
||||
let rest: restm.RestClient = new restm.RestClient('ghaction-upx', 'https://github.com', undefined, {
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (version !== 'latest') {
|
||||
version = `v${version}`;
|
||||
}
|
||||
|
||||
let res: restm.IRestResponse<GitHubRelease> = await rest.get<GitHubRelease>(`/upx/upx/releases/${version}`);
|
||||
if (res.statusCode != 200 || res.result === null) {
|
||||
throw new Error(`Cannot find UPX ${version} release (http ${res.statusCode})`);
|
||||
}
|
||||
|
||||
return res.result.tag_name.replace(/^v/, '');
|
||||
}
|
||||
|
||||
16
src/main.ts
16
src/main.ts
@@ -1,10 +1,10 @@
|
||||
import * as installer from './installer';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as installer from './installer';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
export async function run(silent?: boolean) {
|
||||
export async function run() {
|
||||
try {
|
||||
if (os.platform() == 'darwin') {
|
||||
core.setFailed('Not supported on darwin platform');
|
||||
@@ -14,16 +14,16 @@ export async function run(silent?: boolean) {
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const file = core.getInput('file', {required: true});
|
||||
const args = core.getInput('args');
|
||||
const upx = await installer.getUPX(version);
|
||||
|
||||
if (!fs.existsSync(file)) {
|
||||
core.setFailed(`⛔ File to compress not found: ${file}`);
|
||||
core.setFailed(`File to compress not found: ${file}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🏃 Running UPX...');
|
||||
await exec.exec(`${upx} ${args} ${file}`, undefined, {
|
||||
silent: silent
|
||||
});
|
||||
const upx = await installer.getUPX(version);
|
||||
|
||||
core.info('🏃 Running UPX...');
|
||||
await exec.exec(`${upx} ${args} ${file}`);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"esModuleInterop": true
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user