2019-09-28 18:50:20 +00:00
< p align = "center" >
< img alt = "GoReleaser Logo" src = "https://avatars2.githubusercontent.com/u/24697112?v=3&s=200" height = "140" / >
< h3 align = "center" > GoReleaser Action< / h3 >
< p align = "center" > < a href = "https://github.com/features/actions" > GitHub Action< / a > for GoReleaser< / p >
< p align = "center" >
< a href = "https://github.com/goreleaser/goreleaser-action/releases/latest" > < img alt = "GitHub release" src = "https://img.shields.io/github/release/goreleaser/goreleaser-action.svg?logo=github&style=flat-square" > < / a >
< a href = "https://github.com/marketplace/actions/goreleaser-action" > < img alt = "GitHub marketplace" src = "https://img.shields.io/badge/marketplace-goreleaser--action-blue?logo=github&style=flat-square" > < / a >
2020-05-07 09:47:49 +00:00
< a href = "https://github.com/goreleaser/goreleaser-action/actions?workflow=test" > < img alt = "Test workflow" src = "https://img.shields.io/github/workflow/status/goreleaser/goreleaser-action/test?label=test&logo=github&style=flat-square" > < / a >
< a href = "https://codecov.io/gh/goreleaser/goreleaser-action" > < img alt = "Codecov" src = "https://img.shields.io/codecov/c/github/goreleaser/goreleaser-action?logo=codecov&style=flat-square" > < / a >
2019-11-14 22:02:06 +00:00
< a href = "https://github.com/sponsors/crazy-max" > < img src = "https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square" alt = "Become a sponsor" > < / a >
2019-09-28 18:50:20 +00:00
< / p >
< / p >
2020-05-10 14:02:05 +00:00
___
2019-09-20 20:23:45 +00:00
2020-05-07 00:15:24 +00:00

2020-05-10 14:02:05 +00:00
* [Usage ](#usage )
* [Workflow ](#workflow )
* [Run on new tag ](#run-on-new-tag )
* [Signing ](#signing )
2020-11-29 23:57:19 +00:00
* [Upload artifacts ](#upload-artifacts )
2020-11-06 20:21:22 +00:00
* [Install Only ](#install-only )
2020-05-10 14:02:05 +00:00
* [Customizing ](#customizing )
* [inputs ](#inputs )
* [environment variables ](#environment-variables )
* [Limitation ](#limitation )
2020-11-22 22:34:12 +00:00
* [Development ](#development )
2020-05-10 14:02:05 +00:00
* [License ](#license )
2019-09-28 18:50:20 +00:00
## Usage
2019-09-20 20:23:45 +00:00
2020-05-10 14:02:05 +00:00
### Workflow
2019-09-20 20:23:45 +00:00
```yaml
name: goreleaser
on:
pull_request:
push:
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
2020-01-19 20:52:29 +00:00
uses: actions/checkout@v2
2020-06-15 16:34:01 +00:00
with:
fetch-depth: 0
2019-09-20 20:23:45 +00:00
-
name: Set up Go
2020-05-06 21:12:22 +00:00
uses: actions/setup-go@v2
2019-11-29 01:27:29 +00:00
with:
2020-11-29 23:57:19 +00:00
go-version: 1.15
2019-09-20 20:23:45 +00:00
-
name: Run GoReleaser
2020-05-10 14:22:33 +00:00
uses: goreleaser/goreleaser-action@v2
2019-09-20 20:23:45 +00:00
with:
2021-05-27 03:25:31 +00:00
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
2019-09-20 20:23:45 +00:00
version: latest
args: release --rm-dist
2019-09-20 21:24:04 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-05-27 03:25:31 +00:00
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
2019-09-20 20:23:45 +00:00
```
2020-06-15 16:41:56 +00:00
> **IMPORTANT**: note the `fetch-depth: 0` input in `Checkout` step. It is required for the changelog to work correctly.
2020-05-10 14:02:05 +00:00
### Run on new tag
2020-01-20 17:47:42 +00:00
If you want to run GoReleaser only on new tag, you can use this event:
```yaml
on:
push:
tags:
- '*'
```
Or with a condition on GoReleaser step:
```yaml
-
name: Run GoReleaser
2020-05-10 14:22:33 +00:00
uses: goreleaser/goreleaser-action@v2
2020-01-20 17:47:42 +00:00
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
2020-01-20 17:53:25 +00:00
> For detailed instructions please follow GitHub Actions [workflow syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions#About-yaml-syntax-for-workflows).
2020-01-19 20:35:08 +00:00
2020-05-10 14:02:05 +00:00
### Signing
2021-09-06 20:45:41 +00:00
If [signing is enabled ](https://goreleaser.com/customization/#Signing ) in your GoReleaser configuration, you can use
the [Import GPG ](https://github.com/crazy-max/ghaction-import-gpg ) GitHub Action along with this one:
2020-05-10 14:02:05 +00:00
```yaml
-
name: Import GPG key
2020-05-10 16:42:15 +00:00
id: import_gpg
2021-09-06 20:45:41 +00:00
uses: crazy-max/ghaction-import-gpg@v4
2020-09-07 13:40:41 +00:00
with:
2021-09-06 20:45:41 +00:00
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
2020-09-07 13:40:41 +00:00
passphrase: ${{ secrets.PASSPHRASE }}
2020-05-10 14:02:05 +00:00
-
name: Run GoReleaser
2020-05-10 14:22:33 +00:00
uses: goreleaser/goreleaser-action@v2
2020-05-10 14:02:05 +00:00
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2020-05-10 16:42:15 +00:00
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
2020-05-10 14:02:05 +00:00
```
2020-05-10 16:42:15 +00:00
And reference the fingerprint in your signing configuration using the `GPG_FINGERPRINT` environment variable:
2020-05-10 14:02:05 +00:00
```yaml
signs:
- artifacts: checksum
2020-05-10 16:42:15 +00:00
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
2020-05-10 14:02:05 +00:00
```
2020-11-29 23:57:19 +00:00
### Upload artifacts
For some events like pull request or schedule you might want to store the artifacts somewhere for testing
purpose. You can do that with the [actions/upload-artifact ](https://github.com/actions/upload-artifact ) action:
```yaml
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload assets
uses: actions/upload-artifact@v2
with:
name: myapp
path: dist/*
```
2020-11-06 20:21:22 +00:00
### Install Only
```yaml
steps:
-
name: Install GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
install-only: true
-
name: Show GoReleaser version
run: goreleaser -v
```
2019-09-28 18:50:20 +00:00
## Customizing
2019-09-20 20:23:45 +00:00
2020-05-07 00:42:55 +00:00
### inputs
2019-09-20 20:23:45 +00:00
Following inputs can be used as `step.with` keys
2021-05-27 03:25:31 +00:00
| Name | Type | Default | Description |
|------------------|---------|--------------|------------------------------------------------------------------|
| `distribution` | String | `goreleaser` | GoReleaser distribution, either `goreleaser` or `goreleaser-pro` |
| `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 |
2020-06-15 16:35:23 +00:00
> **¹** 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`.
2019-09-26 12:17:18 +00:00
2020-05-07 00:42:55 +00:00
### environment variables
Following environment variables can be used as `step.env` keys
2021-05-27 03:25:31 +00:00
| Name | Description |
|------------------|---------------------------------------|
| `GITHUB_TOKEN` | [GITHUB_TOKEN ](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token ) as provided by `secrets` |
| `GORELEASER_KEY` | Your [GoReleaser Pro ](https://goreleaser.com/pro ) License Key, in case you are using the `goreleaser-pro` distribution |
2020-05-07 00:42:55 +00:00
## Limitation
`GITHUB_TOKEN` permissions [are limited to the repository ](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret )
2021-05-27 03:25:31 +00:00
that contains your workflow.
2020-05-07 00:42:55 +00:00
If you need to push the homebrew tap to another repository, you must therefore create a custom [Personal Access Token ](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ )
2021-05-27 03:25:31 +00:00
with `repo` permissions and [add it as a secret in the repository ](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets ). If you create a
2020-05-07 00:42:55 +00:00
secret named `GH_PAT` , the step will look like this:
```yaml
-
name: Run GoReleaser
2020-05-10 14:22:33 +00:00
uses: goreleaser/goreleaser-action@v2
2020-05-07 00:42:55 +00:00
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
```
2020-11-22 22:34:12 +00:00
## Development
```
# format code and build javascript artifacts
docker buildx bake pre-checkin
# validate all code has correctly formatted and built
docker buildx bake validate
# run tests
docker buildx bake test
```
2019-09-28 18:50:20 +00:00
## License
2019-09-20 20:23:45 +00:00
MIT. See `LICENSE` for more details.