feat: Add install-only option for using goreleaser in user scripts
This commit is contained in:
parent
c5a3850c06
commit
7007251a74
16
README.md
16
README.md
|
@ -19,6 +19,7 @@ ___
|
||||||
* [Workflow](#workflow)
|
* [Workflow](#workflow)
|
||||||
* [Run on new tag](#run-on-new-tag)
|
* [Run on new tag](#run-on-new-tag)
|
||||||
* [Signing](#signing)
|
* [Signing](#signing)
|
||||||
|
* [Install Only](#install-only)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [environment variables](#environment-variables)
|
* [environment variables](#environment-variables)
|
||||||
|
@ -120,6 +121,20 @@ signs:
|
||||||
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Install Only
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Install GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
with:
|
||||||
|
install-only: true
|
||||||
|
-
|
||||||
|
name: Show GoReleaser version
|
||||||
|
run: goreleaser -v
|
||||||
|
```
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
|
@ -131,6 +146,7 @@ Following inputs can be used as `step.with` keys
|
||||||
| `version`**¹** | String | `latest` | GoReleaser version |
|
| `version`**¹** | String | `latest` | GoReleaser version |
|
||||||
| `args` | String | | Arguments to pass to GoReleaser |
|
| `args` | String | | Arguments to pass to GoReleaser |
|
||||||
| `workdir` | String | `.` | Working directory (below repository root) |
|
| `workdir` | String | `.` | Working directory (below repository root) |
|
||||||
|
| `install-only` | Bool | `false` | Just install GoReleaser |
|
||||||
|
|
||||||
> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
|
> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,13 @@ inputs:
|
||||||
description: 'GoReleaser version'
|
description: 'GoReleaser version'
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
required: false
|
required: false
|
||||||
|
install-only:
|
||||||
|
description: 'Just install GoReleaser'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
args:
|
args:
|
||||||
description: 'Arguments to pass to GoReleaser'
|
description: 'Arguments to pass to GoReleaser'
|
||||||
required: true
|
required: true # not required when install-only=true
|
||||||
workdir:
|
workdir:
|
||||||
description: 'Working directory (below repository root)'
|
description: 'Working directory (below repository root)'
|
||||||
default: '.'
|
default: '.'
|
||||||
|
|
|
@ -339,13 +339,22 @@ const git = __importStar(__webpack_require__(374));
|
||||||
const installer = __importStar(__webpack_require__(480));
|
const installer = __importStar(__webpack_require__(480));
|
||||||
const core = __importStar(__webpack_require__(186));
|
const core = __importStar(__webpack_require__(186));
|
||||||
const exec = __importStar(__webpack_require__(514));
|
const exec = __importStar(__webpack_require__(514));
|
||||||
|
const path_1 = __webpack_require__(622);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput('version') || 'latest';
|
const version = core.getInput('version') || 'latest';
|
||||||
const args = core.getInput('args', { required: true });
|
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
|
||||||
const workdir = core.getInput('workdir') || '.';
|
const workdir = core.getInput('workdir') || '.';
|
||||||
const goreleaser = yield installer.getGoReleaser(version);
|
const goreleaser = yield installer.getGoReleaser(version);
|
||||||
|
core.info(`✅ GoReleaser installed successfully`);
|
||||||
|
if (isInstallOnly) {
|
||||||
|
const goreleaserDir = path_1.dirname(goreleaser);
|
||||||
|
core.addPath(goreleaserDir);
|
||||||
|
core.debug(`Added ${goreleaserDir} to PATH`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const args = core.getInput('args', { required: true });
|
||||||
if (workdir && workdir !== '.') {
|
if (workdir && workdir !== '.') {
|
||||||
core.info(`📂 Using ${workdir} as working directory...`);
|
core.info(`📂 Using ${workdir} as working directory...`);
|
||||||
process.chdir(workdir);
|
process.chdir(workdir);
|
||||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -2,13 +2,22 @@ import * as git from './git';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import {dirname} from 'path';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput('version') || 'latest';
|
const version = core.getInput('version') || 'latest';
|
||||||
const args = core.getInput('args', {required: true});
|
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
|
||||||
const workdir = core.getInput('workdir') || '.';
|
const workdir = core.getInput('workdir') || '.';
|
||||||
const goreleaser = await installer.getGoReleaser(version);
|
const goreleaser = await installer.getGoReleaser(version);
|
||||||
|
core.info(`✅ GoReleaser installed successfully`);
|
||||||
|
if (isInstallOnly) {
|
||||||
|
const goreleaserDir = dirname(goreleaser);
|
||||||
|
core.addPath(goreleaserDir);
|
||||||
|
core.debug(`Added ${goreleaserDir} to PATH`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const args = core.getInput('args', {required: true});
|
||||||
|
|
||||||
if (workdir && workdir !== '.') {
|
if (workdir && workdir !== '.') {
|
||||||
core.info(`📂 Using ${workdir} as working directory...`);
|
core.info(`📂 Using ${workdir} as working directory...`);
|
||||||
|
|
Loading…
Reference in New Issue