-
Notifications
You must be signed in to change notification settings - Fork 9
130 lines (130 loc) · 3.5 KB
/
build.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build
on:
push:
pull_request:
jobs:
fmt:
name: gofmt
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run gofmt
run: ./.github/scripts/gofmt.sh
vet:
name: go vet
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-vet-${{ hashFiles('**/go.sum') }}
restore-keys: go-vet-
- name: Run go vet
run: ./.github/scripts/govet.sh
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
test:
name: go test
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-test-
- name: Run go test
run: ./.github/scripts/gotest.sh
selftest:
name: self-test
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run self-test
run: |
set -euo pipefail
go test -json ./... 2>&1 | tee /tmp/gotest.log | go run ./cmd/gotestfmt -formatter "go run ./cmd/gotestfmt-formatter/main.go"
- name: Run self-test (verbose)
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest-verbose.log | go run ./cmd/gotestfmt -formatter "go run ./cmd/gotestfmt-formatter/main.go"
- name: Upload test log
uses: actions/upload-artifact@v2
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
release:
name: release
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
needs:
- fmt
- vet
- golangci-lint
- test
- selftest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: dist