Skip to content

Commit

Permalink
feat: Add install-only option for using goreleaser in user scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvelsriram committed Nov 4, 2020
1 parent 4441f83 commit 8cb43b4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -19,6 +19,7 @@ ___
* [Workflow](#workflow)
* [Run on new tag](#run-on-new-tag)
* [Signing](#signing)
* [Install Only](#install-only)
* [Customizing](#customizing)
* [inputs](#inputs)
* [environment variables](#environment-variables)
Expand Down Expand Up @@ -120,6 +121,20 @@ signs:
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

### inputs
Expand All @@ -131,6 +146,7 @@ Following inputs can be used as `step.with` keys
| `version`**¹** | String | `latest` | GoReleaser version |
| `args` | String | | Arguments to pass to GoReleaser |
| `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`.
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Expand Up @@ -11,9 +11,13 @@ inputs:
description: 'GoReleaser version'
default: 'latest'
required: false
install-only:
description: 'Just install GoReleaser'
default: 'false'
required: false
args:
description: 'Arguments to pass to GoReleaser'
required: true
required: true # not required when install-only=true
workdir:
description: 'Working directory (below repository root)'
default: '.'
Expand Down
11 changes: 10 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/main.ts
Expand Up @@ -2,13 +2,22 @@ import * as git from './git';
import * as installer from './installer';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {dirname} from 'path';

async function run(): Promise<void> {
try {
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 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 !== '.') {
core.info(`📂 Using ${workdir} as working directory...`);
Expand Down

0 comments on commit 8cb43b4

Please sign in to comment.