-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (122 loc) · 3.24 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
name: Build and Test
on:
pull_request:
branches: [main]
paths:
- '**/Dockerfile'
- '**/.dockerignore'
- .github/**
- '**.go'
- '**.mod'
- '**.sum'
- config/**
- '**/Makefile*'
- '**/documentation.md'
- .golangci.yaml
- .goreleaser.yaml
push:
branches: [main]
jobs:
lint:
strategy:
matrix:
go: ['1.22']
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Make install-tools
run: make install-tools
- name: Make lint
run: make lint
- name: Check Code Generation
run: |
make generate
git diff -s --exit-code || (echo 'Generated code is out of date. Run make generate and commit the changes' && exit 1)
- name: Check packages are up-to-date
run: |
make tidy
git diff -s --exit-code || (echo 'Packages are out of date. Run make tidy and commit the changes' && exit 1)
build:
name: build
strategy:
matrix:
GOOS: [darwin, linux, windows]
GOARCH: [arm64, amd64, '386']
go: ['1.22']
exclude:
- GOOS: darwin
GOARCH: '386'
- GOOS: darwin
GOARCH: arm
- GOOS: windows
GOARCH: arm
- GOOS: windows
GOARCH: arm64
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
if: steps.cache.outputs.cache-hit != 'true'
with:
distribution: goreleaser-pro
version: latest
args: release --clean --snapshot --split
env:
GGOOS: ${{ matrix.GOOS }}
GGOARCH: ${{ matrix.GOARCH }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
test:
strategy:
matrix:
go: ['1.22']
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Make test
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
go-semantic-release:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [lint, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Run go-semantic-release
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.SEMANTIC_RELEASE_GH_PAT }}
changelog-generator-opt: emojis=true
allow-initial-development-versions: true