-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (85 loc) · 2.42 KB
/
ci.yml
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
---
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: reviewdog/action-golangci-lint@v2
test:
strategy:
matrix:
go_version:
- 1.16.x
- 1.17.x
- 1.18.x
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go_version }}
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go_version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go_version }}
- name: test
run: go test -v -race -coverprofile=cover.os-${{ matrix.os }}.ver-${{ matrix.go_version }}.txt -covermode=atomic ./...
- name: upload coverage
uses: codecov/codecov-action@v3
if: ${{ matrix.os == 'ubuntu-latest' && matrix.go_version == '1.18.x' }}
with:
files: ./cover.os-${{ matrix.os }}.ver-${{ matrix.go_version }}.txt
determine_release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
will_release: ${{ steps.determine_release.outputs.new_release_published }}
steps:
- uses: actions/checkout@v3
- id: determine_release
uses: cycjimmy/[email protected]
with:
dry_run: true
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
release:
runs-on: ubuntu-latest
needs:
- test
- lint
- determine_release
if: ${{ needs.determine_release.outputs.will_release }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: cycjimmy/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/setup-go@v3
with:
go-version: '1.18.x'
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go_version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go_version }}
- uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ github.token }}