-
Notifications
You must be signed in to change notification settings - Fork 188
324 lines (288 loc) · 11.4 KB
/
Copy pathrelease.yaml
File metadata and controls
324 lines (288 loc) · 11.4 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
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
branches:
- main
# Manual trigger lets maintainers publish a JS SDK beta on demand without a commit.
workflow_dispatch:
permissions:
contents: read
jobs:
artifacts:
name: Artifacts
# Artifact publishing (container images, etc.) is tag-only.
if: github.ref_type == 'tag'
uses: ./.github/workflows/artifacts.yaml
with:
publish: true
permissions:
contents: read
packages: write
id-token: write
security-events: write
helm-release:
name: Helm Charts
# Helm chart releases are tag-only.
if: github.ref_type == 'tag'
runs-on: depot-ubuntu-latest-8
environment: prod
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
chart: [ openmeter, benthos-collector ]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_conf: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
keep-env-derivations = true
keep-outputs = true
- name: Restore Nix store
uses: nix-community/cache-nix-action/restore@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2
with:
primary-key: ${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-${{
hashFiles('flake.*') }}
restore-prefixes-first-match: |
${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-
${{ runner.os }}-openmeter-nix-build-main-${{ hashFiles('flake.*') }}
${{ runner.os }}-openmeter-nix-build-main-
${{ runner.os }}-openmeter-nix-build-
- name: Package chart
# Untrusted values (github.ref_name, matrix.chart) passed via env to
# avoid shell injection through ${{ ... }} interpolation in run:.
run: nix develop --impure .#ci -c make package-helm-chart CHART="$CHART"
VERSION="$VERSION"
env:
CHART: ${{ matrix.chart }}
VERSION: ${{ github.ref_name }}
- name: Login to GitHub Container Registry
run: echo "$GH_TOKEN" | nix develop --impure .#ci -c helm registry login ghcr.io
--username "$GH_ACTOR" --password-stdin
env:
GH_TOKEN: ${{ github.token }}
GH_ACTOR: ${{ github.actor }}
- name: Push chart to GHCR
run: |
nix develop --impure .#ci -c helm push \
"build/helm/${CHART}-${GITHUB_REF_NAME#v}.tgz" \
oci://ghcr.io/openmeterio/helm-charts
env:
CHART: ${{ matrix.chart }}
GITHUB_REF_NAME: ${{ github.ref_name }}
binary-build:
name: Binary (${{ matrix.goos }}/${{ matrix.goarch }})
# Release binaries are tag-only.
if: github.ref_type == 'tag'
runs-on: depot-ubuntu-latest-8
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_conf: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
keep-env-derivations = true
keep-outputs = true
- name: Restore Nix store
uses: nix-community/cache-nix-action/restore@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2
with:
primary-key: ${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-${{
hashFiles('flake.*') }}
restore-prefixes-first-match: |
${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-
${{ runner.os }}-openmeter-nix-build-main-${{ hashFiles('flake.*') }}
${{ runner.os }}-openmeter-nix-build-main-
${{ runner.os }}-openmeter-nix-build-
- name: Restore go.mod cache if exists
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .devenv/state/go
key: ${{ runner.os }}-openmeter-go-modules-${{ github.ref_name }}-${{
hashFiles('flake.*', 'go.*', '.github/workflows/*.yaml') }}
restore-keys: |
${{ runner.os }}-openmeter-go-modules-${{ github.ref_name }}-${{ hashFiles('flake.*', 'go.*', '.github/workflows/*.yaml') }}
${{ runner.os }}-openmeter-go-modules-${{ github.ref_name }}-
${{ runner.os }}-openmeter-go-modules-main-${{ hashFiles('flake.*', 'go.*', '.github/workflows/*.yaml') }}
${{ runner.os }}-openmeter-go-modules-main
- name: Build benthos-collector binary
# Untrusted github.ref_name passed via env; matrix values are
# workflow-controlled but routed via env for consistency.
run: |
nix develop --impure .#ci -c make build-benthos-collector-release \
GOOS="$GOOS" GOARCH="$GOARCH" VERSION="$VERSION"
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION: ${{ github.ref_name }}
- name: Archive benthos-collector binary
run: |
nix develop --impure .#ci -c make archive-benthos-collector-release \
GOOS="$GOOS" GOARCH="$GOARCH"
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- name: Upload archive
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benthos-collector_${{ matrix.goos }}_${{ matrix.goarch }}
path: build/release/benthos-collector_${{ matrix.goos }}_${{ matrix.goarch
}}.tar.gz
if-no-files-found: error
retention-days: 7
github-release:
name: GitHub Release
# GitHub release creation is tag-only.
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
needs: [ binary-build ]
environment: prod
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download binary archives
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
pattern: "benthos-collector_*"
merge-multiple: true
- name: Compute checksums
working-directory: dist
run: |
sha256sum benthos-collector_*.tar.gz > checksums.txt
cat checksums.txt
- name: Create GitHub release
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--generate-notes \
--verify-tag \
dist/benthos-collector_*.tar.gz \
dist/checksums.txt
# Compute the npm version and dist-tag from the trigger context so the
# reusable workflow below receives them as plain inputs. Tag pushes go to
# the `latest` dist-tag; main pushes and manual dispatches publish a
# per-commit beta.
sdk-javascript-meta:
name: JavaScript SDK Release Meta
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
dist-tag: ${{ steps.meta.outputs.dist-tag }}
steps:
- name: Determine version and npm dist-tag
id: meta
env:
REF_TYPE: ${{ github.ref_type }}
run: |
if [[ "$REF_TYPE" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
echo "dist-tag=latest" >> "$GITHUB_OUTPUT"
else
short_sha="${GITHUB_SHA:0:12}"
echo "version=1.0.0-beta-${short_sha}" >> "$GITHUB_OUTPUT"
echo "dist-tag=beta" >> "$GITHUB_OUTPUT"
fi
sdk-javascript-release:
name: JavaScript SDK Release
# Runs on both tag pushes (stable/pre-release) and main pushes (per-commit beta).
# npm's trusted publisher entry is keyed on caller workflow file + environment,
# so this single caller must serve both channels.
needs: [ sdk-javascript-meta ]
uses: ./.github/workflows/npm-release.yaml
with:
version: ${{ needs.sdk-javascript-meta.outputs.version }}
dist-tag: ${{ needs.sdk-javascript-meta.outputs.dist-tag }}
permissions:
contents: read
id-token: write
sdk-aip-release:
name: AIP TypeScript SDK Release
# The AIP SDK (@openmeter/client) shares the repo version and dist-tag with
# @openmeter/sdk, so it reuses the same meta job. Runs on both tag pushes
# (stable/pre-release) and main pushes (per-commit beta). npm's trusted
# publisher entry is keyed on caller workflow file + environment, so this
# caller must serve both channels.
needs: [ sdk-javascript-meta ]
uses: ./.github/workflows/aip-npm-release.yaml
with:
version: ${{ needs.sdk-javascript-meta.outputs.version }}
dist-tag: ${{ needs.sdk-javascript-meta.outputs.dist-tag }}
permissions:
contents: read
id-token: write
sdk-python-release:
name: Python SDK Release
# Python SDK releases are tag-only (dev Python releases live in sdk-python-dev-release.yaml).
if: github.ref_type == 'tag'
runs-on: depot-ubuntu-latest-8
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Get short SHA
id: get-short-sha
run: |
echo "id=${GITHUB_SHA:0:12}" >> "$GITHUB_OUTPUT"
- name: Set up Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_conf: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
keep-env-derivations = true
keep-outputs = true
- name: Restore Nix store
uses: nix-community/cache-nix-action/restore@7df957e333c1e5da7721f60227dbba6d06080569 # v7.0.2
with:
primary-key: ${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-${{
hashFiles('flake.*') }}
restore-prefixes-first-match: |
${{ runner.os }}-openmeter-nix-build-${{ github.ref_name }}-
${{ runner.os }}-openmeter-nix-build-main-${{ hashFiles('flake.*') }}
${{ runner.os }}-openmeter-nix-build-main-
${{ runner.os }}-openmeter-nix-build-
- name: Publish Python package via Nix make target
run: |
nix develop --impure .#ci -c make -C api/client/python publish-python-sdk
env:
PY_SDK_RELEASE_VERSION: ${{ github.ref_name }}
COMMIT_SHORT_SHA: ${{ steps.get-short-sha.outputs.id }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}