Skip to content

Commit 22afba3

Browse files
committed
feat: add support for GoReleaser (#223)
Given the changes introduced in #220, the `release-please` based release workflow is not working, and thus we need to review the whole automated releasing process. One tool that definitely sees more use in the Go ecosystem is [GoReleaser](https://goreleaser.com), and since we now have a single-module setup, we can freely use it. This PR introduces some of the foundational steps for the new automated release process with GoReleaser.
1 parent c144847 commit 22afba3

File tree

5 files changed

+102
-22
lines changed

5 files changed

+102
-22
lines changed

.github/release.old.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: Release
3+
4+
on: workflow_dispatch
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
tag:
16+
name: Tag
17+
runs-on: ubuntu-latest
18+
permissions:
19+
# NOTE: necessary to apply the git tag.
20+
contents: write
21+
steps:
22+
- name: Checkout source code
23+
uses: actions/checkout@v4
24+
with:
25+
# Using this to pick up the latest tag.
26+
fetch-depth: 0
27+
- name: Get next version
28+
id: semver
29+
uses: ietf-tools/semver-action@v1
30+
with:
31+
token: ${{ github.token }}
32+
branch: main
33+
minorList: 'major, breaking'
34+
patchList: 'feat, fix, bugfix, perf, refactor, test, tests, doc, docs'
35+
- name: Push new version tag
36+
uses: rickstaa/action-create-tag@v1
37+
if: ${{ contains(github.ref, 'main') }} # only push tags if on main branch.
38+
with:
39+
tag: ${{ steps.semver.outputs.next }}
40+
tag_exists_error: false
41+
force_push_tag: true
42+
43+
release:
44+
name: Release
45+
runs-on: ubuntu-latest
46+
needs: [tag]
47+
steps:
48+
- name: Checkout source code
49+
uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
- name: Set up Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version: '1.21'
56+
- name: Run GoReleaser
57+
uses: goreleaser/goreleaser-action@v5
58+
with:
59+
distribution: goreleaser
60+
version: latest
61+
args: release --clean
62+
env:
63+
GITHUB_TOKEN: ${{ github.token }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
# go
55
coverage.txt
6+
7+
dist/

.goreleaser.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
version: 1
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
builds:
9+
- env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
16+
archives:
17+
- format: tar.gz
18+
# this name template makes the OS and Arch compatible with the results of `uname`.
19+
name_template: >-
20+
{{ .ProjectName }}_
21+
{{- title .Os }}_
22+
{{- if eq .Arch "amd64" }}x86_64
23+
{{- else if eq .Arch "386" }}i386
24+
{{- else }}{{ .Arch }}{{ end }}
25+
{{- if .Arm }}v{{ .Arm }}{{ end }}
26+
# use zip for windows archives
27+
format_overrides:
28+
- goos: windows
29+
format: zip
30+
31+
changelog:
32+
sort: asc
33+
filters:
34+
exclude:
35+
- "^docs:"
36+
- "^test:"

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
go-outline
3030
gopkgs
3131
delve
32+
goreleaser
3233

3334
# Linters
3435
nil

0 commit comments

Comments
 (0)