Skip to content

Commit 8031cb2

Browse files
add GoReleaser
1 parent 8dd3866 commit 8031cb2

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ name: Go
22

33
on:
44
push:
5-
branches: [ main ]
5+
tags:
6+
- v*
7+
branches:
8+
- main
69
pull_request:
7-
branches: [ main ]
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: write
815

916
jobs:
1017

@@ -13,14 +20,14 @@ jobs:
1320
runs-on: ubuntu-latest
1421
steps:
1522

23+
- name: Check out code into the Go module directory
24+
uses: actions/checkout@v2
25+
1626
- name: Set up Go 1.x
1727
uses: actions/setup-go@v2
1828
with:
1929
go-version: ^1.18
2030

21-
- name: Check out code into the Go module directory
22-
uses: actions/checkout@v2
23-
2431
- name: Build
2532
run: go build -v .
2633

@@ -29,14 +36,14 @@ jobs:
2936
runs-on: ubuntu-latest
3037
steps:
3138

39+
- name: Check out code into the Go module directory
40+
uses: actions/checkout@v2
41+
3242
- name: Set up Go 1.x
3343
uses: actions/setup-go@v2
3444
with:
3545
go-version: ^1.18
3646

37-
- name: Check out code into the Go module directory
38-
uses: actions/checkout@v2
39-
4047
- name: Test
4148
run: go test -v ./...
4249

@@ -49,3 +56,31 @@ jobs:
4956
# uses: codecov/codecov-action@v2
5057
# with:
5158
# token: ${{ secrets.CODECOV_TOKEN }}
59+
60+
release:
61+
name: Release
62+
needs: [build, test]
63+
runs-on: ubuntu-latest
64+
steps:
65+
66+
- name: Check out code into the Go module directory
67+
uses: actions/checkout@v2
68+
with:
69+
fetch-depth: 0
70+
71+
- name: Fetch all tags
72+
run: git fetch --force --tags
73+
74+
- name: Set up Go 1.x
75+
uses: actions/setup-go@v2
76+
with:
77+
go-version: ^1.18
78+
79+
- name: Run GoReleaser
80+
uses: goreleaser/goreleaser-action@v2
81+
if: startsWith(github.ref, 'refs/tags/')
82+
with:
83+
version: latest
84+
args: release --rm-dist
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- skip: true
6+
changelog:
7+
sort: asc
8+
filters:
9+
exclude:
10+
- '^docs:'
11+
- '^test:'

0 commit comments

Comments
 (0)