Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add install-only option for using goreleaser in user scripts #252

Merged
merged 2 commits into from Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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