* docs: enable instant Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: minify html Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: edit uri Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: remove uneeded meta Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * docs: several improvements Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: broken links Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
4.7 KiB
title |
---|
GitHub Actions |
GoReleaser can also be used within our official GoReleaser Action through GitHub Actions.
You can create a workflow for pushing your releases by putting YAML configuration to
.github/workflows/release.yml
.
Usage
Workflow
Below is a simple snippet to use this action in your workflow:
name: goreleaser
on:
pull_request:
push:
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
!!! info
Note the Unshallow
workflow step. It is required for the changelog to work correctly.
Run on new tag
If you want to run GoReleaser only on new tag, you can use this event:
on:
push:
tags:
- '*'
Or with a condition on GoReleaser step:
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
For detailed instructions please follow GitHub Actions workflow syntax.
Signing
If signing is enabled in your GoReleaser configuration, you can use the Import GPG GitHub Action along with this one:
-
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v1
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 }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
And reference the fingerprint in your signing configuration using the GPG_FINGERPRINT
environment variable:
signs:
- artifacts: checksum
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
Customizing
inputs
Following inputs can be used as step.with
keys
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) |
environment variables
Following environment variables can be used as step.env
keys
Name | Description |
---|---|
GITHUB_TOKEN |
GITHUB_TOKEN as provided by secrets |
Limitation
GITHUB_TOKEN
permissions are limited to the repository that contains your workflow.
If you need to push the homebrew tap to another repository, you must therefore create a custom
Personal Access Token with repo
permissions and add it as a secret in the repository. If you
create a secret named GH_PAT
, the step will look like this:
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}