Skip to content

Commit

Permalink
Merge pull request #180 from grafana/goreleaser
Browse files Browse the repository at this point in the history
Goreleaser
  • Loading branch information
sam boyer authored Jul 31, 2023
2 parents 64e9d78 + 0776436 commit 5a1a452
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name: Go
on:
push:
branches: [ "main" ]
tags:
- '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
Expand All @@ -20,3 +21,21 @@ jobs:

- name: Test
run: go test -v ./...

goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: stable
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
.idea

cmd/thema/thema

dist/
29 changes: 29 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
binary: thema
main: ./cmd/thema

archives:
- format: tar.gz
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: github
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: gen-tag

gen-tag:
git tag $(tag)
git push origin $(tag)
6 changes: 6 additions & 0 deletions docs/release_new_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Release a new version
This process uses [GoReleaser](https://goreleaser.com/install/) to generate the release.

1. Execute `make gen-release tag=your_tag`.
2. To be consistent, all tags should include `v` prefix (ex. v0.1.1). Otherwise, the process couldn't start.
3. When the tag is created, GoReleaser will do the rest of the work for you.

0 comments on commit 5a1a452

Please sign in to comment.