-
Notifications
You must be signed in to change notification settings - Fork 228
319 lines (276 loc) · 11.9 KB
/
base-release.yaml
File metadata and controls
319 lines (276 loc) · 11.9 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: Reusable release workflow
on:
workflow_call:
inputs:
distribution:
required: true
type: string
goos:
required: true
type: string
goarch:
required: true
type: string
runner_os:
required: false
type: string
default: ubuntu-24.04
nightly:
required: false
type: string
default: false
permissions:
contents: read
env:
# renovate: datasource=github-releases packageName=goreleaser/goreleaser-pro
GORELEASER_PRO_VERSION: v2.13.3
jobs:
prev-tag:
outputs:
PREVIOUS_RELEASE_TAG: ${{ steps.prev-tag.outputs.PREVIOUS_RELEASE_TAG }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set goreleaser last tag reference in case of non-nightly release
id: prev-tag
if: inputs.nightly != 'true'
# find previous tag by filtering out nightly tags and binary release (OCB, OpAMP) tags and then choosing the
# second to last tag (last one is the current release)
run: |
prev_tag=$(git tag | grep -v "cmd" | grep -v "nightly" | sort -r --version-sort | head -n 2 | tail -n 1)
echo "PREVIOUS_RELEASE_TAG=$prev_tag" >> "$GITHUB_OUTPUT"
prepare:
strategy:
matrix:
GOOS: ${{ fromJSON(inputs.goos) }}
GOARCH: ${{ fromJSON(inputs.goarch) }}
exclude:
- GOOS: darwin
GOARCH: "386"
- GOOS: darwin
GOARCH: s390x
- GOOS: darwin
GOARCH: ppc64le
- GOOS: darwin
GOARCH: arm
- GOOS: darwin
GOARCH: riscv64
runs-on: ${{ inputs.runner_os }}
permissions:
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- run: ./.github/workflows/scripts/free-disk-space.sh
- uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
with:
cosign-release: "v2.6.1"
- uses: anchore/sbom-action/download-syft@deef08a0db64bfad603422135db61477b16cef56 # v0.22.1
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
if: runner.os != 'Windows'
with:
platforms: arm64,ppc64le,linux/arm/v7,s390x,riscv64
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
if: runner.os != 'Windows'
# Fix slow Go compile and cache restore
# See https://github.com/actions/setup-go/pull/515
- name: Fix slow setup-go cache restore in Windows
if: runner.os == 'Windows'
run: |
echo "GOCACHE=D:\gocache" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "GOMODCACHE=D:\gomodcache" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "GOTMPDIR=D:\gotmp" | Out-File -FilePath $env:GITHUB_ENV -Append
mkdir D:\gotmp
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: "~1.25.0"
check-latest: true
- name: Set nightly enabled
id: nightly-check
if: inputs.nightly == 'true'
run: |
echo "NIGHTLY_FLAG=--nightly" >> "$GITHUB_OUTPUT"
- name: Generate distribution sources
run: make generate-sources
env:
DISTRIBUTIONS: ${{ inputs.distribution }}
- name: Log into Docker.io
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN_COLLECTOR_RELEASES }}
- name: Login to GitHub Package Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create artifacts directory to store build artifacts
if: inputs.distribution == 'otelcol-contrib'
shell: bash
run: mkdir -p distributions/otelcol-contrib/artifacts
# otelcol-contrib is built in a separate stage
- name: Build ${{ inputs.distribution }}
if: inputs.distribution == 'otelcol-contrib'
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_PRO_VERSION }}
workdir: distributions/${{ inputs.distribution }}
args: release --clean --split --timeout 2h --config .goreleaser-build.yaml --release-header-tmpl=../../.github/release-template.md ${{ steps.nightly-check.outputs.NIGHTLY_FLAG }}
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: "7" # Default is 6
GOAMD64: v1
GOPPC64: power8
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_YES: true
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
- name: Move built artifacts
if: inputs.distribution == 'otelcol-contrib'
shell: bash
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/
- name: Show built or downloaded content
if: inputs.distribution == 'otelcol-contrib'
shell: bash
run: ls -laR distributions/otelcol-contrib/artifacts
- uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_PRO_VERSION }}
workdir: distributions/${{ inputs.distribution }}
args: release --clean --split --timeout 2h --release-header-tmpl=../../.github/release-template.md ${{ steps.nightly-check.outputs.NIGHTLY_FLAG }}
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: 7 # Default is 6
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_YES: true
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: artifacts-${{ inputs.distribution }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: distributions/${{ inputs.distribution }}/dist/**/*
if-no-files-found: error
- if: always()
run: ./.github/workflows/scripts/check-disk-space.sh
release:
name: Release
runs-on: ${{ inputs.runner_os }}
needs:
- prepare
- prev-tag
permissions:
id-token: write
packages: write
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
with:
cosign-release: "v2.6.1"
- uses: anchore/sbom-action/download-syft@deef08a0db64bfad603422135db61477b16cef56 # v0.22.1
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
if: runner.os != 'Windows'
with:
platforms: arm64,ppc64le,s390x,riscv64
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
if: runner.os != 'Windows'
# Fix slow Go compile and cache restore
# See https://github.com/actions/setup-go/pull/515
- name: Fix slow setup-go cache restore in Windows
if: runner.os == 'Windows'
run: |
echo "GOCACHE=D:\gocache" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "GOMODCACHE=D:\gomodcache" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "GOTMPDIR=D:\gotmp" | Out-File -FilePath $env:GITHUB_ENV -Append
mkdir D:\gotmp
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: "~1.25.0"
check-latest: true
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
if: runner.os == 'Windows'
with:
pattern: artifacts-${{ inputs.distribution }}-windows-*
path: distributions/${{ inputs.distribution }}/dist
merge-multiple: true
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
if: runner.os != 'Windows'
with:
pattern: artifacts-${{ inputs.distribution }}-darwin-*
path: distributions/${{ inputs.distribution }}/dist
merge-multiple: true
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
if: runner.os != 'Windows'
with:
pattern: artifacts-${{ inputs.distribution }}-linux-*
path: distributions/${{ inputs.distribution }}/dist
merge-multiple: true
- name: Display structure of downloaded files
shell: bash
run: ls -R distributions/${{ inputs.distribution }}/dist
- name: Log into Docker.io
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN_COLLECTOR_RELEASES }}
- name: Login to GitHub Package Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_PRO_VERSION }}
workdir: distributions/${{ inputs.distribution }}
args: continue --merge --timeout 2h
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_YES: true
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GORELEASER_PREVIOUS_TAG: ${{ needs.prev-tag.outputs.PREVIOUS_RELEASE_TAG }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
- if: always()
run: ./.github/workflows/scripts/check-disk-space.sh
create-issue:
name: Create GitHub issue on failed nightly release
runs-on: ubuntu-latest
needs: [release]
if: failure() && inputs.nightly == 'true'
permissions:
issues: write
env:
issue-file: "nightly-release-failure.md"
steps:
- name: Formulate issue
run: |
# create a markdown file that contains details about the failure
echo "---" > ${{ env.issue-file }}
echo "title: Nightly Release Failed" >> ${{ env.issue-file }}
echo "labels: release:blocker" >> ${{ env.issue-file }}
echo "---" >> ${{ env.issue-file }}
echo "The nightly release failed in the following GitHub actions run." >> ${{ env.issue-file }}
echo "* Link to run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> ${{ env.issue-file }}
echo "* Please also check the other distro release runs related to this nightly release" >> ${{ env.issue-file }}
echo "* Triggered by: Nightly scheduled release" >> ${{ env.issue-file }}
echo "" >> ${{ env.issue-file }}
echo "Note: This issue was auto-generated from [base-release.yaml](https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/.github/workflows/base-release.yaml)" >> ${{ env.issue-file }}
- name: Create or update issue
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
update_existing: true
search_existing: open
filename: ${{ env.issue-file }}