-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (136 loc) · 3.69 KB
/
push_main.yaml
File metadata and controls
136 lines (136 loc) · 3.69 KB
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
131
132
133
134
135
136
name: Push Main
on:
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
jobs:
test:
strategy:
matrix:
go-version: ['1.17']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
go version
go mod download
- name: Run Test
run: |
go test -count=10 ./...
lint:
strategy:
matrix:
go-version: ['1.17']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
go install golang.org/x/lint/golint@latest
go mod download
- name: Run Lint
run: |
golint -set_exit_status=1 ./...
coverage:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
- name: Install dependencies
run: |
go install golang.org/x/lint/golint@latest
go mod download
- name: Run Test
run: |
go test -coverprofile=coverage.txt -covermode=atomic -count=10 ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
fail_ci_if_error: true
verbose: true
release_check:
runs-on: ubuntu-latest
outputs:
git_diff: ${{ steps.output.outputs.git_diff }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Diff
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*.go
!**/*_test.go
FILES: |
go.mod
- name: Output Diff
if: env.GIT_DIFF
id: output
run: |
echo "git_diff=${{ env.GIT_DIFF }}" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: [test, lint, release_check]
if: ${{ needs.release_check.outputs.git_diff }}
outputs:
version: ${{ steps.release.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: go-semantic-release/action@v1
id: release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
force-bump-patch-version: true
build:
needs: [release]
if: needs.release.outputs.version != ''
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
goversion: ["1.17"]
exclude:
- goarch: "386"
goos: darwin
- goarch: "386"
goos: windows
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1.36
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_tag: "v${{ needs.release.outputs.version }}"
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: ${{ matrix.goversion }}
project_path: "./cmd/"
binary_name: "jsonpath"
overwrite: true
ldflags: -X "main.Command=jsonpath" -X "main.Version=${{ needs.release.outputs.version }}" -X "main.OS=${{ matrix.goos }}" -X "main.Arch=${{ matrix.goarch }}"