Repository navigation
368 lines (322 loc) · 13 KB
/
Copy pathrelease.yaml
File metadata and controls
368 lines (322 loc) · 13 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
---
# Release Workflow
#
# Builds and publishes:
# - Multi-arch container images (linux/amd64, linux/arm64)
# - Standalone binaries (linux-amd64, linux-arm64, darwin-arm64)
#
# Triggered by release-please or manually.
#
# release-please also publishes a GitHub release for the Helm chart
# (tero-edge-chart-v*). Only app releases (v*) and manual runs build here, and
# only the newest app release moves `latest`. A chart release or a manual run
# once moved `latest` to an untagged commit build.
name: release
on:
release:
types: [published]
workflow_dispatch:
inputs:
distribution:
description: "Distribution to build"
required: true
default: "edge"
type: choice
options:
- edge
- datadog
- otlp
- prometheus
- tail
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: write
packages: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
# =============================================================================
# Binary Builds
# =============================================================================
jobs:
binary-build-linux:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
strategy:
fail-fast: false
matrix:
distribution: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('["{0}"]', inputs.distribution)) || fromJson('["edge", "datadog", "otlp", "prometheus", "tail"]') }}
arch:
- runner: ubuntu-24.04
suffix: linux-amd64
- runner: ubuntu-24.04-arm
suffix: linux-arm64
runs-on: ${{ matrix.arch.runner }}
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Set binary name
run: |
if [ "${{ matrix.distribution }}" = "edge" ]; then
echo "BINARY_NAME=edge" >> $GITHUB_ENV
else
echo "BINARY_NAME=edge-${{ matrix.distribution }}" >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
sudo apt-get update
# hyperscan is x86-only, vectorscan is the ARM-compatible fork
if [ "$(uname -m)" = "x86_64" ]; then
sudo apt-get install -y libhyperscan-dev
else
sudo apt-get install -y libvectorscan-dev
fi
sudo apt-get install -y libzstd-dev zlib1g-dev
- name: Setup Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.16.0
- name: Verify Zig
run: |
which zig
zig version
- name: Fetch Zig dependencies
run: |
for i in 1 2 3 4 5; do zig build --fetch && break || sleep 10; done
- name: Build
run: |
zig build ${{ matrix.distribution }} -Dcpu=baseline -Doptimize=ReleaseSafe \
-Dversion="${{ github.ref_name }}" -Dcommit="${{ github.sha }}"
- name: Prepare artifact
run: |
mkdir -p artifacts
cp zig-out/bin/edge-${{ matrix.distribution }} artifacts/${{ env.BINARY_NAME }}-${{ matrix.arch.suffix }}
chmod +x artifacts/${{ env.BINARY_NAME }}-${{ matrix.arch.suffix }}
- name: Upload artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: binary-${{ matrix.distribution }}-${{ matrix.arch.suffix }}
path: artifacts/*
if-no-files-found: error
retention-days: 1
binary-build-darwin:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
strategy:
fail-fast: false
matrix:
distribution: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('["{0}"]', inputs.distribution)) || fromJson('["edge", "datadog", "otlp", "prometheus", "tail"]') }}
runs-on: macos-15 # Apple Silicon runner
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Set binary name
run: |
if [ "${{ matrix.distribution }}" = "edge" ]; then
echo "BINARY_NAME=edge" >> $GITHUB_ENV
else
echo "BINARY_NAME=edge-${{ matrix.distribution }}" >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
brew install vectorscan zstd
- name: Setup Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.16.0
- name: Verify Zig
run: |
which zig
zig version
- name: Fetch Zig dependencies
run: |
for i in 1 2 3 4 5; do zig build --fetch && break || sleep 10; done
- name: Build
run: |
zig build ${{ matrix.distribution }} -Dcpu=baseline -Doptimize=ReleaseSafe \
-Dversion="${{ github.ref_name }}" -Dcommit="${{ github.sha }}"
- name: Prepare artifact
run: |
mkdir -p artifacts
cp zig-out/bin/edge-${{ matrix.distribution }} artifacts/${{ env.BINARY_NAME }}-darwin-arm64
chmod +x artifacts/${{ env.BINARY_NAME }}-darwin-arm64
- name: Upload artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: binary-${{ matrix.distribution }}-darwin-arm64
path: artifacts/*
if-no-files-found: error
retention-days: 1
upload-binaries:
runs-on: ubuntu-latest
needs: [binary-build-linux, binary-build-darwin]
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v')
timeout-minutes: 10
steps:
- name: Download all artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
path: artifacts
pattern: binary-*
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Upload binaries to release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "## Binaries uploaded to release" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
ls -1 artifacts/ | while read f; do
echo "- \`$f\`" >> "$GITHUB_STEP_SUMMARY"
done
# =============================================================================
# Docker Image Builds
# =============================================================================
docker-build:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
strategy:
fail-fast: false
matrix:
distribution: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('["{0}"]', inputs.distribution)) || fromJson('["edge", "datadog", "otlp", "prometheus", "tail"]') }}
arch:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.arch.runner }}
timeout-minutes: 30
steps:
- name: Prepare
run: |
platform=${{ matrix.arch.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
if [ "${{ matrix.distribution }}" = "edge" ]; then
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
else
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.distribution }}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: Dockerfile
platforms: ${{ matrix.arch.platform }}
build-args: |
DISTRIBUTION=${{ matrix.distribution }}
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY_IMAGE }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
provenance: false
sbom: false
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: digests-${{ matrix.distribution }}-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
docker-merge:
runs-on: ubuntu-latest
needs: docker-build
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
distribution: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('["{0}"]', inputs.distribution)) || fromJson('["edge", "datadog", "otlp", "prometheus", "tail"]') }}
steps:
- name: Prepare
run: |
if [ "${{ matrix.distribution }}" = "edge" ]; then
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
else
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.distribution }}" >> $GITHUB_ENV
fi
- name: Download digests
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.distribution }}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout tags
if: github.event_name == 'release'
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
fetch-depth: 0
fetch-tags: true
# `latest` is the newest app release. A manual run builds a branch, and a
# patch to an older line (1.31.1 after 1.32.0) must not move it back.
- name: Decide latest
id: latest
run: |
enable=false
if [ "${{ github.event_name }}" = "release" ]; then
newest=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -1)
if [ "$newest" = "${{ github.event.release.tag_name }}" ]; then enable=true; fi
echo "newest app tag: $newest, this release: ${{ github.event.release.tag_name }}"
fi
echo "enable=$enable" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY_IMAGE }}
flavor: |
latest=false
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ steps.latest.outputs.enable }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
- name: Summary
run: |
echo "## Docker Release" >> "$GITHUB_STEP_SUMMARY"
echo "**Distribution:** ${{ matrix.distribution }}" >> "$GITHUB_STEP_SUMMARY"
echo "**Image:** ${{ env.REGISTRY_IMAGE }}" >> "$GITHUB_STEP_SUMMARY"
echo "**Tags:** ${{ steps.meta.outputs.tags }}" >> "$GITHUB_STEP_SUMMARY"