Repository navigation
449 lines (435 loc) · 17.1 KB
/
Copy pathrelease.yml
File metadata and controls
449 lines (435 loc) · 17.1 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
name: release
on:
push:
tags:
- "v*.*.*"
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: read
env:
IMAGE: ghcr.io/labstack/pitot
DOCKERHUB_IMAGE: docker.io/labstack/pitot
MCP_PUBLISHER_VERSION: "1.8.1"
MCP_PUBLISHER_LINUX_AMD64_SHA256: "a06c9096dcb9727c13555b6be26c7effa707b01f06a4c561ba7a3635443cf2cc"
jobs:
verify:
name: verify release source
runs-on: ubuntu-24.04
permissions:
contents: read
# Reads the CI run for the tagged commit.
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Validate CalVer tag and lineage
run: |
set -euo pipefail
tag_pattern='^v([0-9]{4})\.([1-9]|1[0-2])\.(0|[1-9][0-9]*)(-(alpha|beta|rc))?$'
[[ "${GITHUB_REF_NAME}" =~ ${tag_pattern} ]] || {
echo "release tag must match v{YYYY}.{M}.{N}[-alpha|-beta|-rc]" >&2
exit 1
}
release_year=$((10#${BASH_REMATCH[1]}))
release_month=${BASH_REMATCH[2]}
release_number=${BASH_REMATCH[3]}
git fetch origin main --tags
git merge-base --is-ancestor "${GITHUB_SHA}" origin/main || {
echo "release tag is not on main" >&2
exit 1
}
tags="$(git tag --list 'v*.*.*')"
while IFS= read -r tag; do
[[ "${tag}" =~ ${tag_pattern} ]] || continue
year=$((10#${BASH_REMATCH[1]}))
month=${BASH_REMATCH[2]}
number=${BASH_REMATCH[3]}
if ((year == release_year && month == release_month && number == release_number)) &&
[ "${tag}" != "${GITHUB_REF_NAME}" ]; then
echo "${tag} shares the release number of ${GITHUB_REF_NAME}" >&2
exit 1
fi
if ((year > release_year ||
(year == release_year && month > release_month) ||
(year == release_year && month == release_month && number > release_number))); then
echo "${GITHUB_REF_NAME} is not the newest release tag (${tag})" >&2
exit 1
fi
done <<< "${tags}"
# Before anything is published, so an unreadable batch format stops the
# release instead of leaving a format change unmarked.
- name: Write upgrade notes
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Compare with the previous published release, not the previous tag:
# a tag whose release failed has no notes to carry its changes.
gh release list --repo "${GITHUB_REPOSITORY}" --exclude-drafts --limit 1000 \
--json tagName --jq '.[].tagName' > "${RUNNER_TEMP}/published-tags"
bash scripts/release-notes.sh "${GITHUB_REF_NAME}" \
< "${RUNNER_TEMP}/published-tags" > "${RUNNER_TEMP}/upgrade-notes.md"
cat "${RUNNER_TEMP}/upgrade-notes.md"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: upgrade-notes
path: ${{ runner.temp }}/upgrade-notes.md
if-no-files-found: error
# The tag is on main (checked above), and CI's push run on main already
# ran every check and the race suite on this exact commit. Reuse that
# result; run the suites here only when no such run passed, for example
# when a newer push cancelled it.
- name: Find CI's result for this commit
id: ci
env:
GH_TOKEN: ${{ github.token }}
run: |
if bash scripts/ci-passed.sh "${GITHUB_SHA}"; then
echo "passed=true" >> "${GITHUB_OUTPUT}"
else
echo "passed=false" >> "${GITHUB_OUTPUT}"
fi
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.2
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
if: steps.ci.outputs.passed != 'true'
with:
version: v2.14.0
args: --help
- run: just ui-deps
# The advisory database changes over time, so the audit runs at release
# even when CI's result is reused.
- run: just ui-audit
- if: steps.ci.outputs.passed != 'true'
run: just check
- if: steps.ci.outputs.passed != 'true'
run: just test-race
# DuckDB needs CGO and this repository carries no cross toolchain, so every
# binary is built on a runner of its own architecture.
binaries:
name: binary (${{ matrix.goos }}/${{ matrix.goarch }})
needs: verify
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: true
matrix:
include:
- { runner: ubuntu-24.04, goos: linux, goarch: amd64 }
- { runner: ubuntu-24.04-arm, goos: linux, goarch: arm64 }
- { runner: macos-15, goos: darwin, goarch: arm64 }
- { runner: macos-15-intel, goos: darwin, goarch: amd64 }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Build
env:
CGO_ENABLED: "1"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
set -euo pipefail
version="${GITHUB_REF_NAME}"
bash scripts/with-duckdb.sh go test ./internal/engine -run 'TestPinnedEngine|TestSQLBoundary' -count=1
mkdir -p stage
bash scripts/with-duckdb.sh go build -trimpath -ldflags "-s -w -X main.version=${version}" -o stage/pitot ./cmd/pitot
for doc in LICENSE NOTICE README.md THIRD_PARTY_NOTICES TRADEMARK.md; do
if [ -f "${doc}" ]; then cp "${doc}" stage/; fi
done
tar -czf "pitot_${version}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz" -C stage .
- name: Smoke test the binary
run: |
set -euo pipefail
got="$(./stage/pitot -version)"
[ "${got}" = "${GITHUB_REF_NAME}" ] || { echo "version = ${got}, want ${GITHUB_REF_NAME}"; exit 1; }
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: pitot_${{ matrix.goos }}_${{ matrix.goarch }}
path: pitot_*.tar.gz
if-no-files-found: error
# Each image layer is built natively and the two are joined into one manifest,
# rather than emulating a CGO build under QEMU.
image:
name: image (${{ matrix.platform }})
needs: verify
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
include:
- { runner: ubuntu-24.04, platform: linux/amd64, arch: amd64 }
- { runner: ubuntu-24.04-arm, platform: linux/arm64, arch: arm64 }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: ${{ matrix.platform }}
build-args: VERSION=${{ github.ref_name }}
provenance: false
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Scan the native image
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
with:
image-ref: ${{ env.IMAGE }}@${{ steps.build.outputs.digest }}
version: v0.74.0
scanners: vuln,secret
severity: HIGH,CRITICAL
exit-code: 1
format: table
- name: Record the digest
run: |
set -euo pipefail
mkdir -p digests
echo "${{ steps.build.outputs.digest }}" > "digests/${{ matrix.arch }}"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: digest-${{ matrix.arch }}
path: digests/*
if-no-files-found: error
manifest:
name: image manifest
needs: image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: digests
pattern: digest-*
merge-multiple: true
- name: Create and push the multi-architecture manifest
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
refs=""
for arch in amd64 arm64; do
digest="$(cat "digests/${arch}")"
[ -n "${digest}" ] || { echo "missing digest for ${arch}"; exit 1; }
refs="${refs} ${IMAGE}@${digest}"
done
for tag in "${version}" latest; do
# shellcheck disable=SC2086
docker buildx imagetools create -t "${IMAGE}:${tag}" ${refs}
done
docker buildx imagetools inspect "${IMAGE}:${version}"
anonymous-image:
name: anonymous GHCR pull
needs: manifest
runs-on: ubuntu-24.04
steps:
- name: Verify the documented public install path
run: |
version="${GITHUB_REF_NAME#v}"
for attempt in 1 2 3 4 5; do
if docker pull "${IMAGE}:${version}"; then
exit 0
fi
echo "anonymous pull attempt ${attempt} failed; retrying" >&2
sleep 10
done
echo "release image is not anonymously pullable" >&2
exit 1
dockerhub:
name: mirror image to Docker Hub
needs: manifest
runs-on: ubuntu-24.04
steps:
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Copy the accepted multi-architecture manifest
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
docker buildx imagetools create \
--tag "${DOCKERHUB_IMAGE}:${version}" \
--tag "${DOCKERHUB_IMAGE}:latest" \
"${IMAGE}:${version}"
source_digest="$(docker buildx imagetools inspect "${IMAGE}:${version}" --format '{{.Manifest.Digest}}')"
mirror_digest="$(docker buildx imagetools inspect "${DOCKERHUB_IMAGE}:${version}" --format '{{.Manifest.Digest}}')"
[ "${mirror_digest}" = "${source_digest}" ] || {
echo "Docker Hub digest ${mirror_digest} does not match GHCR ${source_digest}" >&2
exit 1
}
anonymous-dockerhub:
name: anonymous Docker Hub pull
needs: dockerhub
runs-on: ubuntu-24.04
steps:
- name: Verify the public mirror
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
for attempt in 1 2 3 4 5; do
if docker pull "${DOCKERHUB_IMAGE}:${version}"; then
exit 0
fi
echo "anonymous Docker Hub pull attempt ${attempt} failed; retrying" >&2
sleep 10
done
echo "Docker Hub release image is not anonymously pullable" >&2
exit 1
release:
name: publish release
needs: [binaries, manifest, anonymous-image, anonymous-dockerhub]
runs-on: ubuntu-24.04
permissions:
attestations: write
contents: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: artifacts
pattern: pitot_*
merge-multiple: true
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: upgrade-notes
path: notes
- name: Checksum every archive
run: |
set -euo pipefail
cd artifacts
ls -1 pitot_*.tar.gz
sha256sum pitot_*.tar.gz > SHA256SUMS
cat SHA256SUMS
- name: Attest archives and checksum manifest
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: artifacts/*
- name: Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Maturity lives in the tag; keep this a full release so /releases/latest resolves.
# The upgrade notes from scripts/release-notes.sh are prepended to
# GitHub's generated changelog.
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--notes "$(cat notes/upgrade-notes.md)" \
--generate-notes \
--verify-tag \
artifacts/pitot_*.tar.gz artifacts/SHA256SUMS
verify-release:
name: verify public release
needs: release
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Download and verify every public asset anonymously
env:
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
tmp="$(mktemp -d)"
trap 'rm -rf "${tmp}"' EXIT
cd "${tmp}"
base="https://github.com/labstack/pitot/releases/download/${VERSION}"
curl -fsSLO "${base}/SHA256SUMS"
for target in linux_amd64 linux_arm64 darwin_amd64 darwin_arm64; do
curl -fsSLO "${base}/pitot_${VERSION}_${target}.tar.gz"
done
sha256sum -c SHA256SUMS
for archive in pitot_*.tar.gz; do
listing="${archive}.contents"
tar -tzf "${archive}" > "${listing}"
for document in LICENSE NOTICE README.md THIRD_PARTY_NOTICES TRADEMARK.md; do
grep -Eq "(^|/)${document}$" "${listing}" || {
echo "${archive} does not contain ${document}" >&2
exit 1
}
done
done
mkdir native
tar -xzf "pitot_${VERSION}_linux_amd64.tar.gz" -C native ./pitot
[ "$(native/pitot -version)" = "${VERSION}" ]
- name: Verify the public installer
env:
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
tmp="$(mktemp -d)"
trap 'rm -rf "${tmp}"' EXIT
curl -fsSL "https://raw.githubusercontent.com/labstack/pitot/${VERSION}/scripts/install.sh" -o "${tmp}/install.sh"
PITOT_VERSION="${VERSION}" PITOT_PREFIX="${tmp}/bin" sh "${tmp}/install.sh"
[ "$("${tmp}/bin/pitot" -version)" = "${VERSION}" ]
- name: Verify GitHub build provenance
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
tmp="$(mktemp -d)"
trap 'rm -rf "${tmp}"' EXIT
cd "${tmp}"
base="https://github.com/labstack/pitot/releases/download/${VERSION}"
for target in linux_amd64 linux_arm64 darwin_amd64 darwin_arm64; do
archive="pitot_${VERSION}_${target}.tar.gz"
curl -fsSLO "${base}/${archive}"
gh attestation verify "${archive}" --repo labstack/pitot
done
mcp-registry:
name: publish MCP Registry metadata
needs: verify-release
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set the released version
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
jq --arg version "${version}" '.version = $version' server.json > server.tmp
mv server.tmp server.json
- name: Install the MCP publisher
run: |
set -euo pipefail
archive="mcp-publisher_linux_amd64.tar.gz"
url="https://github.com/modelcontextprotocol/registry/releases/download/v${MCP_PUBLISHER_VERSION}/${archive}"
curl -fsSLo "${archive}" "${url}"
echo "${MCP_PUBLISHER_LINUX_AMD64_SHA256} ${archive}" | sha256sum -c -
tar -xzf "${archive}" mcp-publisher
- name: Validate MCP Registry metadata
run: ./mcp-publisher validate
- name: Authenticate to the MCP Registry
run: ./mcp-publisher login github-oidc
- name: Publish to the MCP Registry
run: ./mcp-publisher publish