-
Notifications
You must be signed in to change notification settings - Fork 4
121 lines (99 loc) · 2.81 KB
/
build.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
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
name: Build
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
- name: Go install
run: go install ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- name: go-fmt-import
uses: Jerome1337/goimports-action@v1.0.2
- name: go-vet
run: go vet -v ./...
- name: gofumpt
run: |
go install mvdan.cc/gofumpt@latest
LIST_OF_FILES=$(gofumpt -l .)
echo "$LIST_OF_FILES"
if [ -n "$LIST_OF_FILES" ]; then
exit 1
fi
- name: go-err-check
run: |
go install github.com/kisielk/errcheck@latest
errcheck ./...
- name: go-static-check
uses: dominikh/staticcheck-action@v1.2.0
with:
install-go: false
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
build:
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
- run: go version
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v6
with:
strip_tag_prefix: v
- name: Generate version info
id: version
run: |
if [ "${{ steps.branch-name.outputs.is_tag }}" = "true" ];
then
echo "version=${{ steps.branch-name.outputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "version=development" >> "$GITHUB_OUTPUT"
fi
echo "commit_id=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
echo "gitRepo=github.com/${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
- name: Compile binaries
run: ./hack/build.sh
env:
GIT_COMMIT: ${{ steps.version.outputs.commit_id }}
GIT_REPO: ${{ steps.version.outputs.gitRepo }}
RELEASE_VERSION: ${{ steps.version.outputs.version }}
- uses: actions/setup-node@v3
if: steps.branch-name.outputs.is_tag == 'true'
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
if: steps.branch-name.outputs.is_tag == 'true'
uses: softprops/action-gh-release@v1
with:
body: ${{steps.github_release.outputs.changelog}}
files: dist/*