-
Notifications
You must be signed in to change notification settings - Fork 4
112 lines (94 loc) · 2.64 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
name: Build
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: write
packages: write
pull-requests: read
jobs:
commitlint:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch-depth is required
- uses: wagoid/commitlint-github-action@v6
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for pre-commit to be able scan history
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: go install ./...
- name: go-vet
run: go vet -v ./...
- name: go-test
run: go test -v ./...
- uses: pre-commit/action@v3.0.1
build:
runs-on: ubuntu-latest
needs:
- commitlint
- test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- 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@v4
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/*