-
Notifications
You must be signed in to change notification settings - Fork 4
205 lines (177 loc) · 5.93 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
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:
if: github.actor != 'liatrio-otel-collector-release[bot]'
strategy:
matrix:
go: ['1.23']
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-all
run: make lint-all
- 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-all
git diff -s --exit-code || (echo 'Packages are out of date. Run make tidy-all and commit the changes' && exit 1)
- name: Check crosslink run
run: |
make crosslink
git diff -s --exit-code || (echo 'Replace statements not updated. Run make crosslink and commit the changes' && exit 1)
build:
name: build
if: github.actor != 'liatrio-otel-collector-release[bot]'
strategy:
matrix:
GOOS: [darwin, linux, windows]
GOARCH: [arm64, amd64, '386']
go: ['1.23']
exclude:
- GOOS: darwin
GOARCH: '386'
- GOOS: darwin
GOARCH: arm
- GOOS: windows
GOARCH: arm
- GOOS: windows
GOARCH: arm64
runs-on:
group: bigger
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: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Build
env:
GGOOS: ${{ matrix.GOOS }}
GGOARCH: ${{ matrix.GOARCH }}
run: make build
# - 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: ${{ steps.generate_token.outputs.token }}
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
test:
if: github.actor != 'liatrio-otel-collector-release[bot]'
strategy:
matrix:
go: ['1.23']
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-all
run: make test-all
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
multimod-prepare-release:
if: ${{ github.ref == 'refs/heads/main' && github.actor != 'liatrio-otel-collector-release[bot]' }}
needs: [lint, build]
runs-on:
group: bigger
permissions:
contents: write
steps:
- name: Generate a token
# if: steps.get_next_version.outputs.hasNextVersion == 'true'
id: generate_token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Clone repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.generate_token.outputs.token }}
fetch-depth: 0
- name: Install tools
run: make install-tools
- name: Get next version
id: get_next_version
uses: thenativeweb/get-next-version@29245d291b9f64a41d76f9b41683610bb4ffeccc # 2.6.3
with:
prefix: v # optional, defaults to ''
- name: Show the next version
run: |
echo ${{ steps.get_next_version.outputs.version }}
echo ${{ steps.get_next_version.outputs.hasNextVersion }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.generate_token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
- name: Multimod release #This is so multimod prerelease can get author info
if: steps.get_next_version.outputs.hasNextVersion == 'true'
run: |
set -eo pipefail
git config --global user.name '${{ steps.generate_token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com'
yq -i '.module-sets.liatrio-otel.version = "${{ steps.get_next_version.outputs.version }}"' versions.yaml
git add .
git commit -m "chore: run multimod to update versions ahead of release(version ${{ steps.get_next_version.outputs.version }})"
make multimod-prerelease
git push