Repository navigation
1040 lines (1010 loc) · 48.8 KB
/
Copy pathrelease.yml
File metadata and controls
1040 lines (1010 loc) · 48.8 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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: release
# A `v*` tag push builds and verifies the release files and attaches them to a
# GitHub Release; nothing leaves GitHub. A manual dispatch on the same tag
# (`gh workflow run release.yml --ref vX.Y.Z`) runs the same jobs, building no
# image the tag run published, then publishes the verified SDK files to PyPI
# and npm and lists the server in the MCP Registry. Every tag publishes the
# server and extractor images to ghcr.io before making the GitHub Release
# visible, so the release's one-line installer never points at an image that
# does not exist. A dispatch with `dry_run` on any branch runs every build,
# check and smoke test and publishes nothing.
# docs/development/release-process.md is the maintainer procedure.
#
# Jobs: version (derive and gate the version) -> preflight (the owner-granted
# prerequisites, in seconds) -> clickhouse (the ClickHouse release the
# installer bundle names, migrated and schema-checked) -> build -> verify
# (inspect the exact files) -> docker (build and scan each image on each
# architecture's own runner) -> docker-tag -> sign (keyless, the indexes
# docker-tag made; every run verifies both images' X.Y.Z tag) and
# docker-smoke (the quickstart and the installer rehearsal) -> github-release
# -> sign-files (keyless, each file the release serves) -> attach-signatures
# -> release-check (tag push only), and pypi, npm, mcp-registry (dispatch
# only). A re-run after a partial publish is safe: the stack bundle keeps the
# ClickHouse release it was first published with, the release is updated in
# place, PyPI skips files it already has, npm and the MCP Registry skip a
# version they already have, a re-run of failed jobs tags the same build again,
# and a run on a tag whose images are published builds and tags none. A tag
# run whose file signing failed is the exception: re-run its failed jobs
# before any dispatch (docs/development/release-process.md).
#
# The PyPI, npm and MCP Registry jobs are dispatch-only, so a tag's GitHub
# Release can be checked before the SDKs and the server listing reach the
# registries.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
dry_run:
description: >-
Rehearse on any branch: build, verify and smoke-test everything, and
publish nothing (no image push, GitHub Release or registry upload)
type: boolean
required: false
default: false
clickhouse_image:
description: >-
An exact ClickHouse release for a bundle not yet published (e.g.
clickhouse/clickhouse-server:26.9.18.11), when `latest` names a bad one;
for a final it is used in place of any release its candidates on this
commit published
required: false
default: ""
allow_clickhouse_downgrade:
description: >-
Publish a bundle whose ClickHouse release is older than one a recent
published bundle names (installs that upgrade then run an older
server on data a newer one wrote)
type: boolean
required: false
default: false
# One release run per tag at a time; a second run waits instead of cancelling
# a publish halfway.
concurrency:
group: release-${{ github.ref }}${{ inputs.dry_run && '-dry-run' || '' }}
cancel-in-progress: false
permissions:
contents: read
env:
# Every image the docker matrix builds (a unit test keeps the two equal).
IMAGES: ghcr.io/clickhouse/loom ghcr.io/clickhouse/loom-extractor
PYTHON_VERSION: "3.12"
NODE_VERSION: "22"
UV_VERSION: "0.12.19"
jobs:
version:
name: Version from the tag or the server
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.parse.outputs.version }}
prerelease: ${{ steps.parse.outputs.prerelease }}
previous: ${{ steps.checks.outputs.previous }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0 # the tags: the chart's previous version and the candidate order
# prepare.py's checks need only the standard library; the project's Python runs them.
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
# A dispatch from a branch would otherwise take the branch name as the
# version and publish it. A dry run publishes nothing, so it runs on any
# ref, at the version the server names.
- name: Parse the version from the tag or the server
id: parse
env:
REF: ${{ github.ref }}
DRY_RUN: ${{ inputs.dry_run == true }}
run: |
case "$REF" in
refs/tags/v*) VERSION="${REF#refs/tags/v}" ;;
*)
if [ "$DRY_RUN" != true ]; then
echo "::error::run the release on a v* tag, not $REF (or dispatch it with -f dry_run=true)"
exit 1
fi
VERSION=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' server/__init__.py)
;;
esac
# A prerelease is a release candidate, X.Y.Z-rc.N.
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
echo "::error::$VERSION is not X.Y.Z or X.Y.Z-rc.N"
exit 1
fi
PRERELEASE=false
[[ "$VERSION" == *-* ]] && PRERELEASE=true
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
echo "Releasing v$VERSION (prerelease: $PRERELEASE, dry run: $DRY_RUN)"
# Every version file names the tag's final, the candidate order holds, and the
# chart's own version moved (release-process.md); check-tag skips off the tag's
# commit in a dry run. `previous` is the tag the generated release notes start
# from (the release CLI's --notes-start-tag).
- name: Version files, the candidate order and the chart
id: checks
env:
VERSION: ${{ steps.parse.outputs.version }}
DRY_RUN: ${{ inputs.dry_run == true }}
run: |
dry_run=()
[ "$DRY_RUN" != true ] || dry_run=(--dry-run)
python3 scripts/release/prepare.py check "$VERSION"
python3 scripts/release/prepare.py check-tag "${dry_run[@]}" "$VERSION"
python3 scripts/release/prepare.py check-chart "$VERSION"
previous=$(python3 scripts/release/prepare.py previous "$VERSION")
echo "previous=$previous" >> "$GITHUB_OUTPUT"
# What only an owner can grant (a public repository; ghcr.io packages this
# workflow can push and anyone can pull), checked before the builds rather
# than at the push. A dry run reports each as a warning.
preflight:
name: Release prerequisites
needs: version
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
images_published: ${{ steps.images.outputs.published }}
permissions:
contents: read
packages: write # the push probe asks for the access the docker job uses
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check the owner-granted prerequisites
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY_PRIVATE: ${{ github.event.repository.private }}
MODE: ${{ inputs.dry_run && 'report' || 'strict' }}
run: bash scripts/release/preflight.sh "$MODE"
# The registry dispatch on a tag whose images the tag run published keeps
# them: an uncached rebuild would move the version's tags onto other bytes.
- name: Are this version's images published
id: images
if: ${{ !inputs.dry_run }}
env:
VERSION: ${{ needs.version.outputs.version }}
REVISION: ${{ github.sha }}
run: |
# shellcheck disable=SC2086 # one argument per image
published=$(bash scripts/release/published_images.sh "$VERSION" $IMAGES)
echo "published=$published" >> "$GITHUB_OUTPUT"
# The ClickHouse release the bundle pins (scripts/release/release_clickhouse.sh
# says which), so an installed Loom version keeps its ClickHouse; it is
# migrated and checked here first.
clickhouse:
name: The ClickHouse release the bundle names
needs: [version, preflight]
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
image: ${{ steps.resolve.outputs.image }}
env:
LOOM_CH_HOST: localhost
LOOM_CH_PORT: "8123"
LOOM_CH_USER: loom
LOOM_CH_PASSWORD: loomdev
LOOM_CH_DATABASE: loom
LOOM_CH_SECURE: "false"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0 # the candidate tags on this commit
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
id: python
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
version: ${{ env.UV_VERSION }}
- name: Install Loom from uv.lock (no extras)
env:
PYTHON_PATH: ${{ steps.python.outputs.python-path }}
run: |
uv sync --locked --python "${PYTHON_PATH}"
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
# release_clickhouse.sh decides which release, in order of
# preference. A downgrade is refused here so the run stops before it
# builds and pushes images; github-release checks again before it uploads.
- name: Which ClickHouse release the bundle names
id: resolve
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
CLICKHOUSE_IMAGE: ${{ inputs.clickhouse_image }}
ALLOW_DOWNGRADE: ${{ inputs.allow_clickhouse_downgrade }}
run: |
image=$(bash scripts/release/release_clickhouse.sh "$VERSION")
echo "image=$image" >> "$GITHUB_OUTPUT"
- name: Migrate a fresh server of that release and check schema.sql
env:
LOOM_CLICKHOUSE_IMAGE: ${{ steps.resolve.outputs.image }}
run: |
bash dev/ci_start_clickhouse.sh
python -m server.core.schema.migrate
make schema-check
build:
name: Build the release files
needs: [version, clickhouse]
runs-on: ubuntu-latest
timeout-minutes: 30
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
package-manager-cache: false
# The SDK sources carry the tag's version, so every published file names it.
# The Python SDK takes its PEP 440 form (1.2.0rc1 for 1.2.0-rc.1): the
# build backend writes the version into METADATA as given, and the verify
# step and PyPI read the normalized one.
- name: Sync the Python SDK version to the tag
id: sync-python
run: |
python -m pip install --require-hashes --only-binary=:all: -r scripts/release/requirements.txt
python - <<'PY'
import os, pathlib, re
from packaging.version import Version
version = str(Version(os.environ["VERSION"]))
p = pathlib.Path("sdk/python/pyproject.toml")
p.write_text(re.sub(r'^version = ".*"$', f'version = "{version}"', p.read_text(), count=1, flags=re.M))
v = pathlib.Path("sdk/python/loom/_version.py")
v.write_text(re.sub(r'__version__ = ".*"', f'__version__ = "{version}"', v.read_text()))
PY
# check-version.mjs compares package.json, package-lock.json (npm version
# rewrites both) and src/version.ts.
- name: Sync the TypeScript SDK version to the tag
working-directory: sdk/typescript
run: |
npm version --no-git-tag-version --allow-same-version "$VERSION"
sed -i "s/export const SDK_VERSION = \".*\";/export const SDK_VERSION = \"$VERSION\";/" src/version.ts
- name: Build Python sdist + wheel
run: |
python -m pip install --require-hashes --only-binary=:all: -r scripts/release/requirements.txt
python -m build sdk/python --outdir release/python
- name: npm ci
working-directory: sdk/typescript
run: npm ci --no-audit --no-fund
# Lint, types, version across sources, README examples and unit tests
# gate a registry publish.
- name: npm run check (before a registry publish)
if: github.event_name == 'workflow_dispatch'
working-directory: sdk/typescript
run: npm run check
# ESM + CJS build, dist tests, publint and arethetypeswrong.
- name: Build the npm tarball
working-directory: sdk/typescript
run: |
npm run check:dist
mkdir -p ../../release/npm
npm pack --pack-destination ../../release/npm
- name: Zip the coding-agent plugins
run: |
mkdir -p release/plugins
( cd integrations && zip -qr "../release/plugins/loom-claude-code-plugin-v${VERSION}.zip" claude-code-plugin -x "claude-code-plugin/tests/*" )
( cd integrations && zip -qr "../release/plugins/loom-codex-plugin-v${VERSION}.zip" codex-plugin )
zip -q "release/plugins/loom-claude-code-plugin-v${VERSION}.zip" LICENSE NOTICE THIRD_PARTY_NOTICES
zip -q "release/plugins/loom-codex-plugin-v${VERSION}.zip" LICENSE NOTICE THIRD_PARTY_NOTICES
ls -la release/*
# docs/getting-started/agent-setup.md with this release's version and commit.
- name: Render agent-setup.txt
run: |
python scripts/release/agent_setup.py --version "$VERSION" --commit "$GITHUB_SHA" \
--out release/agent/agent-setup.txt
# The bundle, its checksum and install.sh, which installs this version.
- name: Build the source-free Compose installer bundle
env:
CLICKHOUSE_IMAGE: ${{ needs.clickhouse.outputs.image }}
run: |
python scripts/release/build_stack_bundle.py build --version "$VERSION" \
--clickhouse-image "$CLICKHOUSE_IMAGE"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-files
path: release/
if-no-files-found: error
retention-days: ${{ inputs.dry_run && 1 || 30 }} # as long as the run can be re-run
verify:
name: Verify the release files
needs: [version, clickhouse, build]
runs-on: ubuntu-latest
timeout-minutes: 15
env:
VERSION: ${{ needs.version.outputs.version }}
CLICKHOUSE_IMAGE: ${{ needs.clickhouse.outputs.image }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: release
# Names, embedded versions and contents of exactly the files that are
# attached and published: one wheel and one sdist, one npm tarball, two
# plugin zips without tests and with the executable bits git records.
- name: Files carry this version and the expected contents
run: |
python -m pip install --require-hashes --only-binary=:all: -r scripts/release/requirements.txt
python - <<'PY'
import json, os, pathlib, subprocess, sys, tarfile, zipfile
from packaging.version import Version
sys.path.insert(0, os.getcwd())
from scripts.release.build_stack_bundle import FILES, pinned_image, stamped
version = os.environ["VERSION"]
pyv = str(Version(version))
errors = []
def names(d):
return sorted(p.name for p in pathlib.Path("release", d).iterdir())
py = names("python")
want = [f"clickhouse_loom-{pyv}-py3-none-any.whl", f"clickhouse_loom-{pyv}.tar.gz"]
if sorted(py) != sorted(want):
errors.append(f"python files {py}, expected {want}")
else:
with zipfile.ZipFile(f"release/python/{want[0]}") as z:
meta = next(n for n in z.namelist() if n.endswith(".dist-info/METADATA"))
text = z.read(meta).decode()
if f"\nVersion: {pyv}\n" not in text or "\nName: clickhouse-loom\n" not in text:
errors.append("wheel METADATA does not name clickhouse-loom " + pyv)
npm = names("npm")
tgz = f"clickhouse-loom-{version}.tgz"
if npm != [tgz]:
errors.append(f"npm files {npm}, expected [{tgz}]")
else:
with tarfile.open(f"release/npm/{tgz}") as t:
pkg = json.load(t.extractfile("package/package.json"))
if (pkg["name"], pkg["version"]) != ("@clickhouse/loom", version):
errors.append(f"npm package.json names {pkg['name']}@{pkg['version']}")
if not any(n.startswith("package/dist/") for n in t.getnames()):
errors.append("npm tarball has no dist/")
for plugin, manifest, excluded in (
("claude-code-plugin", ".claude-plugin/plugin.json", "tests/"),
("codex-plugin", ".codex-plugin/plugin.json", None),
):
path = f"release/plugins/loom-{plugin}-v{version}.zip"
if not os.path.exists(path):
errors.append(f"missing {path}")
continue
with zipfile.ZipFile(path) as z:
info = {i.filename: i for i in z.infolist()}
if f"{plugin}/{manifest}" not in info:
errors.append(f"{path} has no {manifest}")
for required_notice in ("LICENSE", "NOTICE", "THIRD_PARTY_NOTICES"):
if required_notice not in info:
errors.append(f"{path} has no {required_notice}")
if excluded and any(n.startswith(f"{plugin}/{excluded}") for n in info):
errors.append(f"{path} ships {excluded}")
staged = subprocess.run(
["git", "ls-files", "-s", f"integrations/{plugin}"],
check=True, capture_output=True, text=True,
).stdout.splitlines()
for line in staged:
mode, _, _, name = line.split(maxsplit=3)
entry = info.get(name.removeprefix("integrations/"))
if mode == "100755" and entry and not (entry.external_attr >> 16) & 0o111:
errors.append(f"{entry.filename} lost its executable bit")
if len(names("plugins")) != 2:
errors.append(f"plugin files {names('plugins')}, expected two zips")
stack = names("stack")
expected_stack = ["install.sh", "loom-stack.tar.gz", "loom-stack.tar.gz.sha256"]
if stack != expected_stack:
errors.append(f"stack files {stack}, expected {expected_stack}")
else:
archive = pathlib.Path("release/stack/loom-stack.tar.gz")
checksum = pathlib.Path("release/stack/loom-stack.tar.gz.sha256").read_text().split()[0]
import hashlib
if hashlib.sha256(archive.read_bytes()).hexdigest() != checksum:
errors.append("stack bundle sha256 does not match")
with tarfile.open(archive) as t:
# Every file the builder ships, so the two cannot drift apart.
required = {"loom-stack/VERSION"} | {f"loom-stack/{d}" for d in FILES.values()}
missing = required - set(t.getnames())
if missing:
errors.append(f"stack bundle is missing {sorted(missing)}")
release_version = t.extractfile("loom-stack/VERSION").read().decode().strip()
pinned = pinned_image(archive)
if pinned != os.environ["CLICKHOUSE_IMAGE"]:
errors.append(f"stack bundle names {pinned}, not the checked release")
if release_version != version:
errors.append(f"stack bundle version {release_version}, expected {version}")
if stamped(version) not in pathlib.Path("release/stack/install.sh").read_text():
errors.append(f"install.sh does not install {version}")
contract = pathlib.Path("release/agent/agent-setup.txt").read_text()
for pin in (f'PIN_VERSION = "{version}"', f'PIN_COMMIT = "{os.environ["GITHUB_SHA"]}"'):
if pin not in contract:
errors.append(f"agent-setup.txt does not pin {pin}")
if "<version>" in contract or "<commit>" in contract:
errors.append("agent-setup.txt leaves a <version> or <commit> unfilled")
for e in errors:
print(f"::error::{e}")
sys.exit(1 if errors else 0)
PY
# The wheel alone in a clean venv: it imports, talks through a mocked
# transport, and ships py.typed and the license.
- name: Smoke-test the wheel
run: |
python -m venv /tmp/sdk-smoke
/tmp/sdk-smoke/bin/pip install release/python/*.whl
/tmp/sdk-smoke/bin/python scripts/gates/sdk_wheel_smoke.py release/python/*.whl
docker:
# The server's image, and the document extractor service's (extractor/), which
# the compose stack and the chart run beside it at the same version. Each
# architecture builds on its own runner, is pushed by digest and scanned;
# docker-tag joins the two. None is built when the version's are published.
# A dry run exports each image to an artifact instead of pushing it, without
# the provenance and SBOM attestations, which only a registry keeps.
name: Docker (${{ matrix.artifact }}, ${{ matrix.arch }})
if: ${{ needs.preflight.outputs.images_published != 'true' }}
needs: [version, preflight, verify]
strategy:
# A dry run reports every image's failure; a release stops at the first.
fail-fast: ${{ !inputs.dry_run }}
matrix:
artifact: [server, extractor]
arch: [amd64, arm64]
include:
- artifact: server
image: ghcr.io/clickhouse/loom
file: Dockerfile
pin: image.digest
# Title and description are the repository's, metadata-action's defaults.
labels: |
org.opencontainers.image.documentation=https://loom.clickhouse.com/docs/
- artifact: extractor
image: ghcr.io/clickhouse/loom-extractor
file: extractor/Dockerfile
pin: extractor.image.digest
labels: |
org.opencontainers.image.title=loom-extractor
org.opencontainers.image.description=Loom's document extractor service, which parses originals apart from the server
org.opencontainers.image.documentation=https://loom.clickhouse.com/docs/
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
permissions:
contents: read
packages: write # Push release images to the registry.
env:
DRY_RUN: ${{ inputs.dry_run == true }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to ghcr.io
if: ${{ !inputs.dry_run }}
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image tags
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ matrix.image }}
# Added to metadata-action's defaults: the extractor's own title and description,
# and both images' documentation link.
labels: ${{ matrix.labels }}
# docker-tag adds `:latest` when this is the highest final version;
# metadata-action would add it to any final version.
flavor: latest=false
# A dry run on a branch has no tag to derive them from.
tags: |
type=semver,pattern={{version}},value=v${{ needs.version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=v${{ needs.version.outputs.version }}
- name: Build + push by digest (linux/${{ matrix.arch }})
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: ${{ matrix.file }}
platforms: linux/${{ matrix.arch }}
# By digest only: docker-tag adds the version tags once every image has scanned.
# A dry run's goes to a file instead, which docker-smoke loads.
outputs: ${{ inputs.dry_run && format('type=docker,name={0}:{1},dest={2}/image.tar', matrix.image, needs.version.outputs.version, runner.temp) || format('type=image,name={0},push-by-digest=true,name-canonical=true,push=true', matrix.image) }}
labels: ${{ steps.meta.outputs.labels }}
# The server's /v1/health build_commit, which the agent setup contract checks.
build-args: ${{ matrix.artifact == 'server' && format('LOOM_BUILD_COMMIT={0}', github.sha) || '' }}
provenance: ${{ !inputs.dry_run && 'mode=max' || 'false' }}
sbom: ${{ !inputs.dry_run }}
# Built from the package archives as they are now: a cached apt layer
# would ship, or fail the scan on, a package fixed since it was cached.
no-cache: true
# Fails the release on a critical CVE that has a fixed package.
- name: Scan the image
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
env:
TRIVY_PLATFORM: linux/${{ matrix.arch }}
with:
image-ref: ${{ !inputs.dry_run && format('{0}@{1}', matrix.image, steps.build.outputs.digest) || '' }}
input: ${{ inputs.dry_run && format('{0}/image.tar', runner.temp) || '' }}
severity: CRITICAL
ignore-unfixed: true
exit-code: "1"
# Tagged by docker-tag, which waits for every image to scan.
- name: Record the scanned image, digest and tags
env:
IMAGE: ${{ matrix.image }}
PIN: ${{ matrix.pin }}
DIGEST: ${{ steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
mkdir -p scanned
printf '%s\n' "$IMAGE" > scanned/image
printf '%s\n' "$PIN" > scanned/pin
printf '%s\n' "$DIGEST" > scanned/digest
printf '%s\n' "$TAGS" > scanned/tags
if [ "$DRY_RUN" = true ]; then mv "$RUNNER_TEMP/image.tar" scanned/image.tar; fi
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: scanned-${{ matrix.artifact }}-${{ matrix.arch }}
path: scanned/
retention-days: ${{ inputs.dry_run && 1 || 30 }} # as long as the run can be re-run
compression-level: ${{ inputs.dry_run && 1 || 6 }}
docker-tag:
name: Tag every scanned image
if: ${{ !inputs.dry_run && needs.preflight.outputs.images_published != 'true' }}
needs: [version, preflight, docker]
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
digests: ${{ steps.tag.outputs.digests }}
permissions:
contents: read
packages: write # Write release image tags to the registry.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Asked when it is applied, so a re-run never moves Latest back (make_latest.py).
- name: Is this the highest final version
id: latest
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
# An assignment, so a failed listing fails the step (an echo of it would not).
run: |
latest=$(python3 scripts/release/make_latest.py "$VERSION")
echo "latest=$latest" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to ghcr.io
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:
pattern: scanned-*
# No image is tagged until every one has scanned: each image's tags name
# one index of its amd64 and arm64 digests. A failure here can leave one
# image tagged and not the other; re-running this job tags both again.
- name: Tag the scanned images
id: tag
env:
LATEST: ${{ steps.latest.outputs.latest }}
run: |
digests=()
set -- scanned-*/
[ "$#" = 4 ] || { echo "::error::expected the server's and the extractor's scans on amd64 and arm64, got: $*"; exit 1; }
for artifact in server extractor; do
set -- scanned-"$artifact"-*/
image=$(cat "$1image") pin=$(cat "$1pin")
version_tag=$(head -n 1 "$1tags")
args=()
while read -r tag; do [ -n "$tag" ] && args+=(-t "$tag"); done <"$1tags"
[ "$LATEST" != true ] || args+=(-t "$image:latest")
sources=()
for dir in "$@"; do sources+=("$image@$(cat "${dir}digest")"); done
docker buildx imagetools create "${args[@]}" "${sources[@]}"
# jq -e: a failed inspect leaves no digest, which fails the step, never an empty pin.
digest=$(docker buildx imagetools inspect "$version_tag" --format '{{json .Manifest}}' | jq -re .digest)
echo "Pin $image with \`$pin: $digest\`" >> "$GITHUB_STEP_SUMMARY"
digests+=("$image@$digest")
done
echo "digests=${digests[*]}" >> "$GITHUB_OUTPUT"
# The run that tags signs the indexes it made, by digest; every run then
# verifies the signature users check, so a wrong identity, or an image tag
# moved since, is refused. The GitHub Release and the registries wait for it.
sign:
name: Sign and verify both images
if: ${{ !cancelled() && !inputs.dry_run && (needs.docker-tag.result == 'success' || needs.preflight.outputs.images_published == 'true') }}
needs: [version, preflight, docker-tag]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write # Write image signatures to the registry.
id-token: write # the keyless signature's certificate names this workflow and tag
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
- name: Log in to ghcr.io
id: login
if: ${{ needs.docker-tag.result == 'success' }}
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sign each image's index
id: sign
if: ${{ needs.docker-tag.result == 'success' }}
env:
DIGESTS: ${{ needs.docker-tag.outputs.digests }}
run: |
# shellcheck disable=SC2086 # one argument per image
for ref in $DIGESTS; do cosign sign --yes "$ref"; done
- name: Verify both images' signatures
id: verify
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
# shellcheck disable=SC2086 # one argument per image
bash scripts/release/verify_signatures.sh "$VERSION" $IMAGES
docker-smoke:
name: Released quickstart (${{ matrix.arch }})
# A dry run smokes the images its docker jobs exported, a release the ones
# docker-tag published, and a dispatch on a published tag the published ones.
if: >-
${{ !cancelled() && needs.clickhouse.result == 'success' && needs.verify.result == 'success' && (
(needs.docker.result == 'success' && needs.docker-tag.result == 'success') ||
(inputs.dry_run && needs.docker.result == 'success' && needs.docker-tag.result == 'skipped') ||
needs.preflight.outputs.images_published == 'true') }}
needs: [version, preflight, clickhouse, verify, docker, docker-tag]
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0 # the release tags, for the previous release's installer
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
package-manager-cache: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: release
- name: Install dashboard browser-test dependencies
working-directory: frontend
run: |
npm ci --no-audit --no-fund
npx playwright install --with-deps chromium
- name: Load this run's images (dry run)
if: ${{ inputs.dry_run }}
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: scanned-*-${{ matrix.arch }}
- name: Load this run's images into Docker (dry run)
if: ${{ inputs.dry_run }}
run: for tar in scanned-*/image.tar; do docker load -i "$tar"; done
- name: Fresh installer stack, compiler indexing and dashboard provider recovery
env:
VERSION: ${{ needs.version.outputs.version }}
CLICKHOUSE_IMAGE: ${{ needs.clickhouse.outputs.image }}
run: |
python3 scripts/gates/docker_quickstart_smoke.py --image "ghcr.io/clickhouse/loom:$VERSION" \
--extractor-image "ghcr.io/clickhouse/loom-extractor:$VERSION" \
--clickhouse-image "$CLICKHOUSE_IMAGE"
# The commit /v1/health reports, which agent-setup.txt pins.
- name: The server image names the tag's commit
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
built=$(docker run --rm --entrypoint printenv "ghcr.io/clickhouse/loom:$VERSION" LOOM_BUILD_COMMIT)
[ "$built" = "$GITHUB_SHA" ] || { echo "::error::the image names commit '$built', not $GITHUB_SHA"; exit 1; }
# The release's own install.sh and bundle, before they are published: the
# one-liner in clean Debian, Ubuntu and Alpine containers (install, round
# trip, re-run, a refused downgrade) and an upgrade over the previous
# release's installer (previous_release_files.sh). The quickstart above
# pulled a release's images; a dry run loaded them.
- name: The one-line installer in clean containers
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
python3 scripts/gates/installer_rehearsal.py --release-dir release/stack --upgrade \
--image "ghcr.io/clickhouse/loom:$VERSION" \
--extractor-image "ghcr.io/clickhouse/loom-extractor:$VERSION"
github-release:
name: GitHub Release (artifacts attached)
if: ${{ !cancelled() && !inputs.dry_run && needs.verify.result == 'success' && needs.docker-smoke.result == 'success' && needs.sign.result == 'success' }}
needs: [version, verify, sign, docker-smoke]
runs-on: ubuntu-latest
timeout-minutes: 10
# One publish at a time across every tag, so the downgrade check below
# sees the bundle another tag's run published a moment ago.
concurrency:
group: release-publish
cancel-in-progress: false
outputs:
latest: ${{ steps.latest.outputs.latest }}
permissions:
contents: write # Create the release and attach its artifacts.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: release
# Asked when it is applied, so a re-run never moves Latest back (make_latest.py).
- name: Is this the highest final version
id: latest
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
# An assignment, so a failed listing fails the step (an echo of it would not).
run: |
latest=$(python3 scripts/release/make_latest.py "$VERSION")
echo "latest=$latest" >> "$GITHUB_OUTPUT"
# Replacing an asset deletes it first: a failed upload would leave an
# installed version without its bundle, and its pin with it. A published
# bundle and its checksum stay; a checksum file the release lost is
# written again from the published bundle. A new bundle never names an
# older ClickHouse release than a recent published one (prereleases
# included), unless the dispatch allows it.
- name: Keep this version's published bundle, or refuse a ClickHouse downgrade
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
ALLOW_DOWNGRADE: ${{ inputs.allow_clickhouse_downgrade }}
run: |
status=0
bash scripts/release/published_bundle.sh "$VERSION" published || status=$?
case $status in
0)
rm release/stack/loom-stack.tar.gz release/stack/loom-stack.tar.gz.sha256
if [ -f published/loom-stack.tar.gz.sha256 ]; then
(cd published && sha256sum -c loom-stack.tar.gz.sha256)
else
(cd published && sha256sum loom-stack.tar.gz) >release/stack/loom-stack.tar.gz.sha256
fi
;;
3)
image=$(python3 scripts/release/build_stack_bundle.py pinned-in release/stack/loom-stack.tar.gz)
bash scripts/release/refuse_downgrade.sh "$image"
;;
*) exit "$status" ;;
esac
- name: Is there a release for this tag already
id: existing
env:
GH_TOKEN: ${{ github.token }}
# A single lookup includes drafts and keeps API failures distinct from absence.
run: |
release=$(gh api graphql \
-f query='query($owner: String!, $name: String!, $tag: String!) {
repository(owner: $owner, name: $name) {
release(tagName: $tag) { id }
}
}' \
-f owner="${GITHUB_REPOSITORY%%/*}" -f name="${GITHUB_REPOSITORY#*/}" -f tag="$GITHUB_REF_NAME" \
--jq '.data.repository | if has("release") then .release != null else error("Missing release result") end')
echo "release=$release" >>"$GITHUB_OUTPUT"
- name: Create or update the release with notes and files
id: publish-release
env:
GH_TOKEN: ${{ github.token }}
VERSION_EXISTS: ${{ steps.existing.outputs.release }}
PREVIOUS_TAG: ${{ needs.version.outputs.previous }}
PRERELEASE: ${{ needs.version.outputs.prerelease }}
LATEST: ${{ steps.latest.outputs.latest }}
run: |
files=(release/python/* release/npm/*.tgz release/plugins/*.zip release/stack/* release/agent/agent-setup.txt)
for file in "${files[@]}"; do
test -f "$file" || { echo "::error::Missing release file $file"; exit 1; }
done
if [ "$VERSION_EXISTS" = true ]; then
# Keep the existing notes, which may include edits from maintainers.
gh release upload "$GITHUB_REF_NAME" "${files[@]}" --clobber --repo "$GITHUB_REPOSITORY"
else
notes=(--generate-notes)
if [ -n "$PREVIOUS_TAG" ]; then notes+=(--notes-start-tag "$PREVIOUS_TAG"); fi
gh release create "$GITHUB_REF_NAME" "${files[@]}" --draft --verify-tag --title "$GITHUB_REF_NAME" \
"${notes[@]}" --prerelease="$PRERELEASE" --repo "$GITHUB_REPOSITORY"
fi
# Publish separately so a failed response leaves the release and its assets available.
gh release edit "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --draft=false \
--prerelease="$PRERELEASE" --latest="$LATEST" --repo "$GITHUB_REPOSITORY"
# Signs the files the release serves, downloaded as users download them, when
# they are the bytes this run built (sign_release_files.sh). Its own job, so
# no step that can write to the release can also request the OIDC token;
# attach-signatures uploads the Sigstore bundles.
sign-files:
name: Sign the release files
if: ${{ !cancelled() && needs.github-release.result == 'success' }}
needs: [version, github-release]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write # each file's keyless signature names this workflow and tag
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: built
- name: Sign and verify each file
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }} # the release listing only; files download anonymously
run: |
bash scripts/release/download_release_files.sh "$VERSION" files
bash scripts/release/sign_release_files.sh "$VERSION" files built signed
cp signed/*.sigstore.json files/
bash scripts/release/verify_release_files.sh "$VERSION" files
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-signatures
path: signed/*.sigstore.json # only the new ones: a kept bundle is left in place
if-no-files-found: error
overwrite: true # a re-run of this job replaces the earlier attempt's
retention-days: 30 # as long as the run can be re-run
attach-signatures:
name: Attach the Sigstore bundles to the release
if: ${{ !cancelled() && needs.sign-files.result == 'success' }}
needs: sign-files
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # Attach signatures to the existing release.
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-signatures
path: sigstore
- name: Upload the Sigstore bundles
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$GITHUB_REF_NAME" sigstore/*.sigstore.json --clobber --repo "$GITHUB_REPOSITORY"
# The published release as a user meets it, signed in to nothing. The SDKs are
# checked by a dispatch of release-check after the registry dispatch.
release-check:
name: Published release from outside
if: ${{ !cancelled() && needs.attach-signatures.result == 'success' && github.event_name == 'push' }}
needs: [version, attach-signatures]
uses: ./.github/workflows/release-check.yml
with:
version: ${{ needs.version.outputs.version }}
pypi:
name: PyPI (clickhouse-loom)
# !cancelled(): an implicit success() would read the docker jobs a dispatch on
# a published tag skips, and skip this one too.
if: ${{ !cancelled() && needs.github-release.result == 'success' && github.event_name == 'workflow_dispatch' }}
needs: github-release
runs-on: ubuntu-latest
timeout-minutes: 15
environment:
name: pypi
url: https://pypi.org/p/clickhouse-loom
permissions:
id-token: write # trusted publishing (OIDC)
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: release
- name: Publish the verified wheel and sdist (trusted publishing)
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: release/python/
skip-existing: true
npm:
name: npm (@clickhouse/loom)
# !cancelled(): as in the pypi job.
if: ${{ !cancelled() && needs.github-release.result == 'success' && github.event_name == 'workflow_dispatch' }}
needs: [version, github-release]
runs-on: ubuntu-latest
timeout-minutes: 15
environment:
name: npm
url: https://www.npmjs.com/package/@clickhouse/loom
permissions:
id-token: write # npm trusted publishing (OIDC) and provenance
env:
VERSION: ${{ needs.version.outputs.version }}
PRERELEASE: ${{ needs.version.outputs.prerelease }}
LATEST: ${{ needs.github-release.outputs.latest }}
steps:
# Trusted publishing needs npm 11.5.1 or later, which current Node 24
# ships; the tarball itself is built on NODE_VERSION.
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-files
path: release
# `latest` follows the GitHub Release's Latest: a prerelease goes to `next`
# and a patch to an older line to its own `release-X.Y`, so `npm install`
# keeps the highest final.
- name: Publish the verified tarball (provenance)
id: publish
run: |
if npm view "@clickhouse/loom@$VERSION" version >/dev/null 2>&1; then
echo "@clickhouse/loom@$VERSION is already published"
exit 0
fi
if [ "$PRERELEASE" = true ]; then
TAG=next
elif [ "$LATEST" = true ]; then
TAG=latest
else
TAG="release-${VERSION%.*}"
fi
npm publish "release/npm/clickhouse-loom-$VERSION.tgz" --provenance --access public --tag "$TAG"