-
Notifications
You must be signed in to change notification settings - Fork 12
58 lines (46 loc) · 1.44 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: GoReleaser
on:
push:
branches: [ main ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ main ]
permissions:
contents: write
jobs:
release:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # It is required for GoReleaser to work properly.
# This is needed if you use fields like TagBody, TagSubject or
# TagContents in your templates.
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
# Getting go version from the go.mod file
go-version-file: 'go.mod'
- run: go version
# Sanity check before publishing
- name: Test all
run: go test -v ./...
- name: Set goreleaser snapshot env
run: if [[ $GITHUB_REF != refs/tags/v* ]]; then echo "goreleaser_snapshot=--snapshot"; fi >> $GITHUB_ENV
- name: Read variables
run: |
echo "goreleaser_snapshot=${{ env.goreleaser_snapshot }}"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # V6.1.0
with:
distribution: goreleaser
version: latest
args: release --clean ${{ env.goreleaser_snapshot }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}