• Stars
    star
    791
  • Rank 55,562 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub Action for GoReleaser

GoReleaser Logo

GoReleaser Action

GitHub Action for GoReleaser

GitHub release GitHub marketplace Test workflow Codecov


GoRelease Action

Usage

GoReleaser Action runs goreleaser, please follow its docs for more information about how to customize what GoReleaser do.

Workflow

name: goreleaser

on:
  pull_request:
  push:

permissions:
  contents: write

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      -
        name: Set up Go
        uses: actions/setup-go@v4
      -
        name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v4
        with:
          # either 'goreleaser' (default) or 'goreleaser-pro'
          distribution: goreleaser
          version: latest
          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 }}

IMPORTANT: note the fetch-depth: 0 input in Checkout 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@v4
        if: startsWith(github.ref, 'refs/tags/')
        with:
          version: latest
          args: release --clean
        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@v5
        with:
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          passphrase: ${{ secrets.PASSPHRASE }}
      -
        name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v4
        with:
          version: latest
          args: release --clean
        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}"]

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 action:

      -
        name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v4
        with:
          version: latest
          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/*

Install Only

steps:
  -
    name: Install GoReleaser
    uses: goreleaser/goreleaser-action@v4
    with:
      install-only: true
  -
    name: Show GoReleaser version
    run: goreleaser -v

Customizing

inputs

Following inputs can be used as step.with keys

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

ΒΉ 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.

outputs

Following outputs are available

Name Type Description
artifacts JSON Build result artifacts
metadata JSON Build result metadata

environment variables

Following environment variables can be used as step.env keys

Name Description
GITHUB_TOKEN GITHUB_TOKEN as provided by secrets and requires contents:write
GORELEASER_KEY Your GoReleaser Pro License Key, in case you are using the goreleaser-pro distribution

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@v4
        with:
          version: latest
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}

Migrating from v3

If you need the auto-snapshot feature, take a look at this example repository: it's a minimal working example with all you need.

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

License

MIT. See LICENSE for more details.

More Repositories

1

goreleaser

Deliver Go binaries as fast and easily as possible
Go
12,780
star
2

nfpm

nFPM is Not FPM - a simple deb, rpm, apk and arch linux packager written in Go
Go
1,965
star
3

godownloader

[DEPRECATED] Download Go binaries as fast and easily as possible.
Go
442
star
4

chglog

chglog is a changelog management library and tool
Go
240
star
5

goreleaser-cross

Docker image for Golang cross-compiling with CGO
Shell
118
star
6

fileglob

A file globbing library.
Go
62
star
7

goreleaser-pro

Deliver Go binaries as fast, easily and pro as possible.
Go
53
star
8

goreleaser-example-supply-chain

Example goreleaser + github actions config with keyless signing and SBOM generation
Go
52
star
9

goreleaser-cross-example

Go
28
star
10

example

Example GoReleaser project
Go
26
star
11

goreleaser-example-zig-cgo

A showcase of using Zig to cross-compile Go application with GoReleaser
Go
25
star
12

homebrew-tap

Homebrew Formulae to @goreleaser binaries, powered by @goreleaser
Ruby
11
star
13

old-go-releaser

[DEPRECATED] A script to build and release go binaries to github releases
Shell
10
star
14

community

GoReleaser Community Resources
9
star
15

goreleaser-example-slsa-provenance

A demonstration of showing how to use πŸ’ƒSLSA 3 Generic Generator with GoReleaser to release artifacts while generating signed SLSA provenance
Go
9
star
16

get

Get the latest goreleaser binary
Shell
8
star
17

archive

Moved to https://github.com/goreleaser/goreleaser/tree/master/pkg/archive
Go
5
star
18

scoop-bucket

Scoop bucket for @goreleaser binaries, powered by @goreleaser
5
star
19

goinstall

[DEPRECATED] curl | bash goreleaser projects
Shell
4
star
20

goreleaser-pro-split-merge-example

Example repository using the upcoming split/merge feature of @goreleaser pro
Dockerfile
4
star
21

goreleaser-azure-devops-extension

Azure DevOps Extension for GoReleaser
TypeScript
3
star
22

artwork

logos & art
3
star
23

.github

Smarty
3
star
24

goreleaser-pro-split-merge-example-real

Example repository using the upcoming split/merge feature of @goreleaser pro to build windows docker images
Dockerfile
3
star
25

fish-food

Gofish Rigs to @goreleaser binaries, powered by @goreleaser
Lua
2
star
26

users

graphs GoReleaser usage in the wild
Go
2
star
27

nur

nix user repository for goreleaser
Nix
2
star
28

goreleaser-cross-toolchains

Dockerfile
2
star
29

goreleaser-pro-monorepo-example

GoReleaser Pro Monorepo example with GitHub Actions
Go
2
star
30

example-mod-proxy

Example of project using @goreleaser's gomod.proxy feature.
Go
2
star
31

example-simple

Probably the simplest possible @goreleaser example
Makefile
1
star
32

goreleaser-example-sign-with-env

Example signing with cosign using --key=env://KEY
Go
1
star
33

tf

Terraform resources for GoReleaser's organization
HCL
1
star
34

acceptance-tests

Acceptance tests setup et al for GoReleaser.
Shell
1
star