feat: install-only

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-05-02 22:44:03 -03:00
parent 48ab6ba97a
commit dbf74e34eb
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
7 changed files with 48 additions and 6 deletions

View File

@ -50,3 +50,29 @@ jobs:
files: | files: |
./bin/firefox-history-merger* ./bin/firefox-history-merger*
args: -fq args: -fq
install-only:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
version:
- latest
- v4.0.2
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: UPX
uses: ./
with:
version: ${{ matrix.version }}
install-only: true
-
name: verify
run: >
which upx
upx --version

View File

@ -53,9 +53,10 @@ Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|---------------|---------|-----------|---------------------------------| |---------------|---------|-----------|---------------------------------|
| `version` | String | `latest` | UPX version. Example: `v3.95` | | `version` | String | `latest` | UPX version. Example: `v3.95` |
| `files` | String | | Newline-delimited list of path globs for files to compress (**required**) | | `files` | String | | Newline-delimited list of path globs for files to compress |
| `args` | String | | Arguments to pass to UPX | | `args` | String | | Arguments to pass to UPX |
| `install-only` | String | `false` | Install upx, but do not run it |
## Limitation ## Limitation

View File

@ -21,6 +21,11 @@ inputs:
deprecationMessage: 'file is deprecated. Please use files input instead.' deprecationMessage: 'file is deprecated. Please use files input instead.'
description: 'File to compress' description: 'File to compress'
required: false required: false
install-only:
description: 'Just install upx'
default: 'false'
required: false
runs: runs:
using: 'node16' using: 'node16'

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -6,13 +6,15 @@ export interface Inputs {
version: string; version: string;
files: string[]; files: string[];
args: string; args: string;
installOnly: boolean;
} }
export async function getInputs(): Promise<Inputs> { export async function getInputs(): Promise<Inputs> {
return { return {
version: core.getInput('version') || 'latest', version: core.getInput('version') || 'latest',
files: getInputList(core.getInput('files') || core.getInput('file'), true), files: getInputList(core.getInput('files') || core.getInput('file'), true),
args: core.getInput('args') args: core.getInput('args'),
installOnly: core.getBooleanInput('install-only')
}; };
} }

View File

@ -1,4 +1,5 @@
import * as os from 'os'; import * as os from 'os';
import * as path from 'path';
import * as context from './context'; import * as context from './context';
import * as installer from './installer'; import * as installer from './installer';
import * as core from '@actions/core'; import * as core from '@actions/core';
@ -14,6 +15,13 @@ async function run(): Promise<void> {
const inputs: context.Inputs = await context.getInputs(); const inputs: context.Inputs = await context.getInputs();
const upx = await installer.getUPX(inputs.version); const upx = await installer.getUPX(inputs.version);
if (inputs.installOnly) {
const dir = path.dirname(upx);
core.addPath(dir);
core.debug(`Added ${dir} to PATH`);
return;
}
const files: string[] = context.resolvePaths(inputs.files); const files: string[] = context.resolvePaths(inputs.files);
if (files.length == 0) { if (files.length == 0) {
core.warning(`No files were found. Please check the 'files' input.`); core.warning(`No files were found. Please check the 'files' input.`);