-
Notifications
You must be signed in to change notification settings - Fork 38
69 lines (65 loc) · 1.97 KB
/
test-tag.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
name: Test/Tag
on:
pull_request:
push:
branches:
- main
jobs:
unit-test-windows:
if: ${{ !startsWith(github.event.head_commit.message, 'tag') }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: go test -v ./...
unit-test-linux:
if: ${{ !startsWith(github.event.head_commit.message, 'tag') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: go test -v -covermode=count -coverprofile=.coverage.out ./... -coverpkg=./...
- name: Coveralls upload
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: .coverage.out
lint:
if: ${{ !startsWith(github.event.head_commit.message, 'tag') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- run: golangci-lint run -v
tag:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- unit-test-linux
- unit-test-windows
- lint
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0' # https://github.com/actions/checkout/issues/217
token: ${{ secrets.CI_TOKEN }}
- name: Tag
run: |
version=$(.github/semver.sh)
git config user.name github-actions
git config user.email [email protected]
sed "s/\"v[0-9]*\.[0-9]*\.[0-9]*\"/\"$version\"/" cmd/root.go > cmd/_root.go
mv cmd/_root.go cmd/root.go
git add cmd/root.go
git commit -m "tag: $version"
git tag "$version"
git push
git push --tags