Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
name: 'Usage of goreleaser-action GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: '~> v1'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GoReleaser Action
GitHub Action for GoReleaser
What is GoReleaser?
The GoReleaser GitHub Action is designed to automate the release process for Go projects. This action runs GoReleaser, which helps in building and publishing Go binaries and packages. Follow the GoReleaser documentation for detailed customization options.
How to Run GoReleaser on New Tag
To run GoReleaser only on new tags, use the following event configuration in your workflow file:
on:
push:
tags:
- '*'
Or, add a condition to the GoReleaser step:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
version: '~> v1'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
How to Enable Signing
If signing is enabled in your GoReleaser configuration, you can use the Import GPG GitHub Action along with GoReleaser:
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v1'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
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}"]
How to Upload Artifacts
To store artifacts for testing purposes during events like pull requests or schedules, use the actions/upload-artifact
action:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v1'
args: release --clean
workdir: myfolder
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: myapp
path: myfolder/dist/*
How to Install Only
To install GoReleaser without running it, use the following steps:
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
- name: Show GoReleaser version
run: goreleaser -v
Customizing Inputs
The following inputs can be used as step.with
keys to customize the GoReleaser action:
How to Specify Distribution
GoReleaser distribution, either goreleaser
or goreleaser-pro
.
with:
distribution: goreleaser-pro
How to Specify Version
GoReleaser version. Can be a fixed version like v0.117.0
or a max satisfying semver one like `~>