2019-01-24 20:10:14 +02:00
|
|
|
---
|
|
|
|
title: GitHub Actions
|
|
|
|
---
|
|
|
|
|
2020-05-07 14:13:46 +02:00
|
|
|
GoReleaser can also be used within our official [GoReleaser Action][goreleaser-action]
|
|
|
|
through [GitHub Actions][actions].
|
2019-01-24 20:10:14 +02:00
|
|
|
|
2020-05-07 14:13:46 +02:00
|
|
|
You can create a workflow for pushing your releases by putting YAML configuration to
|
|
|
|
`.github/workflows/release.yml`.
|
2019-08-30 15:18:25 +02:00
|
|
|
|
2020-05-10 17:40:51 +02:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Workflow
|
|
|
|
|
2019-09-29 16:32:25 +02:00
|
|
|
Below is a simple snippet to use this action in your workflow:
|
2019-12-24 15:52:45 +02:00
|
|
|
|
2019-08-30 15:18:25 +02:00
|
|
|
```yaml
|
2019-09-29 16:32:25 +02:00
|
|
|
name: goreleaser
|
|
|
|
|
2019-08-30 15:18:25 +02:00
|
|
|
on:
|
2019-09-29 16:32:25 +02:00
|
|
|
pull_request:
|
2019-08-30 15:18:25 +02:00
|
|
|
push:
|
2019-09-29 16:32:25 +02:00
|
|
|
|
2019-08-30 15:18:25 +02:00
|
|
|
jobs:
|
2019-09-29 16:32:25 +02:00
|
|
|
goreleaser:
|
2019-08-30 15:18:25 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-09-29 16:32:25 +02:00
|
|
|
-
|
|
|
|
name: Checkout
|
2020-01-14 15:11:21 +02:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
-
|
|
|
|
name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
2019-09-29 16:32:25 +02:00
|
|
|
-
|
|
|
|
name: Set up Go
|
2020-05-07 14:13:46 +02:00
|
|
|
uses: actions/setup-go@v2
|
2019-12-24 15:52:45 +02:00
|
|
|
with:
|
2020-05-07 14:13:46 +02:00
|
|
|
go-version: 1.14
|
2019-09-29 16:32:25 +02:00
|
|
|
-
|
|
|
|
name: Run GoReleaser
|
2020-05-10 17:40:51 +02:00
|
|
|
uses: goreleaser/goreleaser-action@v2
|
2019-09-29 16:32:25 +02:00
|
|
|
with:
|
|
|
|
version: latest
|
2019-12-24 15:52:45 +02:00
|
|
|
args: release --rm-dist
|
2019-10-21 13:33:19 +02:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2019-01-24 20:10:14 +02:00
|
|
|
```
|
|
|
|
|
2020-05-10 21:57:11 +02:00
|
|
|
!!! info
|
|
|
|
Note the `Unshallow` workflow step. It is required for the changelog to work correctly.
|
2020-01-14 15:11:21 +02:00
|
|
|
|
2020-05-10 17:40:51 +02:00
|
|
|
### Run on new tag
|
|
|
|
|
2020-01-26 16:50:53 +02: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 17:40:51 +02:00
|
|
|
uses: goreleaser/goreleaser-action@v2
|
2020-01-26 16:50:53 +02:00
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
args: release --rm-dist
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
```
|
|
|
|
|
2020-05-11 00:47:55 +02:00
|
|
|
!!! tip
|
|
|
|
For detailed instructions please follow GitHub Actions [workflow syntax][syntax].
|
2019-09-29 16:32:25 +02:00
|
|
|
|
2020-05-10 17:40:51 +02:00
|
|
|
### Signing
|
|
|
|
|
|
|
|
If [signing is enabled][signing] in your GoReleaser configuration, you can use the [Import GPG][import-gpg]
|
|
|
|
GitHub Action along with this one:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
-
|
|
|
|
name: Import GPG key
|
2020-05-10 18:16:17 +02:00
|
|
|
id: import_gpg
|
2020-05-24 17:20:48 +02:00
|
|
|
uses: crazy-max/ghaction-import-gpg@v2
|
2020-05-10 17:40:51 +02:00
|
|
|
env:
|
|
|
|
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
|
|
|
PASSPHRASE: ${{ secrets.PASSPHRASE }}
|
|
|
|
-
|
|
|
|
name: Run GoReleaser
|
|
|
|
uses: goreleaser/goreleaser-action@v2
|
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
args: release --rm-dist
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2020-05-10 18:16:17 +02:00
|
|
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
2020-05-10 17:40:51 +02:00
|
|
|
```
|
|
|
|
|
2020-05-10 18:16:17 +02:00
|
|
|
And reference the fingerprint in your signing configuration using the `GPG_FINGERPRINT` environment variable:
|
2020-05-10 17:40:51 +02:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
signs:
|
|
|
|
- artifacts: checksum
|
2020-05-10 18:16:17 +02:00
|
|
|
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
2020-05-10 17:40:51 +02:00
|
|
|
```
|
|
|
|
|
2019-09-29 16:32:25 +02:00
|
|
|
## Customizing
|
|
|
|
|
2020-05-07 14:13:46 +02:00
|
|
|
### inputs
|
2019-01-26 01:47:17 +02:00
|
|
|
|
2019-09-29 16:32:25 +02:00
|
|
|
Following inputs can be used as `step.with` keys
|
2019-03-14 16:06:26 +02:00
|
|
|
|
2020-05-26 18:24:59 +02:00
|
|
|
| Name | Type | Default | Description |
|
|
|
|
|-----------|--------|----------|-------------------------------------------|
|
|
|
|
| `version` | String | `latest` | GoReleaser version. Example: `v0.117.0` |
|
|
|
|
| `args` | String | | Arguments to pass to GoReleaser |
|
|
|
|
| `workdir` | String | `.` | Working directory (below repository root) |
|
2019-01-26 01:47:17 +02:00
|
|
|
|
2020-05-07 14:13:46 +02:00
|
|
|
### environment variables
|
|
|
|
|
|
|
|
Following environment variables can be used as `step.env` keys
|
|
|
|
|
|
|
|
| Name | Description |
|
|
|
|
|----------------|-------------------------------------------------------|
|
|
|
|
| `GITHUB_TOKEN` | [GITHUB_TOKEN][github-token] as provided by `secrets` |
|
|
|
|
|
|
|
|
## Limitation
|
|
|
|
|
|
|
|
`GITHUB_TOKEN` permissions [are limited to the repository][about-github-token] that contains your workflow.
|
|
|
|
|
|
|
|
If you need to push the homebrew tap to another repository, you must therefore create a custom
|
|
|
|
[Personal Access Token][pat] with `repo` permissions and [add it as a secret in the repository][secrets]. If you
|
|
|
|
create a secret named `GH_PAT`, the step will look like this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
-
|
|
|
|
name: Run GoReleaser
|
2020-05-10 17:40:51 +02:00
|
|
|
uses: goreleaser/goreleaser-action@v2
|
2020-05-07 14:13:46 +02:00
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
args: release --rm-dist
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
|
|
|
```
|
|
|
|
|
2019-09-29 16:32:25 +02:00
|
|
|
[goreleaser-action]: https://github.com/goreleaser/goreleaser-action
|
2019-01-24 20:10:14 +02:00
|
|
|
[actions]: https://github.com/features/actions
|
2019-08-30 15:18:25 +02:00
|
|
|
[syntax]: https://help.github.com/en/articles/workflow-syntax-for-github-actions#About-yaml-syntax-for-workflows
|
2020-05-27 09:58:38 +02:00
|
|
|
[signing]: https://goreleaser.com/customization/sign/
|
2020-05-10 17:40:51 +02:00
|
|
|
[import-gpg]: https://github.com/crazy-max/ghaction-import-gpg
|
2020-05-07 14:13:46 +02:00
|
|
|
[github-token]: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
|
|
|
[about-github-token]: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret
|
|
|
|
[pat]: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
|
|
|
|
[secrets]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
|