Repository navigation
946 lines (801 loc) · 29.8 KB
/
Copy pathci.yml
File metadata and controls
946 lines (801 loc) · 29.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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check formatting
run: make fmt-check
- name: Lint Rust wrappers and catalogs
run: make lint-rust
- name: Lint TypeScript SDK
run: make lint-sdk
- name: Check project consistency
run: make check-consistency
# All four suites run for PRs, main pushes, and release tags alike.
rust-test-suite:
name: rust-test (${{ matrix.suite }})
needs: quality
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
suite: [core, release-fixtures, bindings, feature-gates]
env:
POLYGLOT_API_CONTRACT: ${{ github.workspace }}/docs/api-capabilities.json
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: rust-test-${{ matrix.suite }}
- name: Setup Python
if: matrix.suite == 'core' || matrix.suite == 'release-fixtures'
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
if: matrix.suite == 'core' || matrix.suite == 'release-fixtures'
uses: astral-sh/setup-uv@v7
- name: Extract core fixtures
if: matrix.suite == 'core'
run: make extract-fixtures
- name: Extract release-test fixtures
if: matrix.suite == 'release-fixtures'
run: make extract-all-fixtures
- name: Run Rust suite
run: make test-rust-ci-${{ matrix.suite }}
# Not named ffi-*: this is an internal same-run artifact, not a release archive.
- name: Upload FFI library for Go integration tests
if: matrix.suite == 'bindings'
uses: actions/upload-artifact@v7
with:
name: rust-ci-ffi-linux-x86_64
path: target/ffi_release/libpolyglot_sql_ffi.so
if-no-files-found: error
retention-days: 7
# Preserve the required check name and all existing downstream needs: rust-test.
rust-test:
if: always()
needs: [quality, rust-test-suite]
runs-on: ubuntu-latest
steps:
- name: Require every Rust suite to pass
env:
QUALITY_RESULT: ${{ needs.quality.result }}
SUITES_RESULT: ${{ needs.rust-test-suite.result }}
run: |
if [[ "$QUALITY_RESULT" != success || "$SUITES_RESULT" != success ]]; then
echo "::error::Rust verification did not pass (quality=$QUALITY_RESULT, suites=$SUITES_RESULT)"
exit 1
fi
python-fast-check:
runs-on: ubuntu-latest
env:
POLYGLOT_API_CONTRACT: ${{ github.workspace }}/docs/api-capabilities.json
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install uv
uses: astral-sh/setup-uv@v7
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Python bindings tests
run: make test-python
- name: Python bindings typecheck
run: make typecheck-python
- name: Build Python API documentation
run: make python-docs-build
go-sdk:
# The fork consumes only the Rust crate and Python package.
if: github.repository == 'tobilg/polyglot'
needs: rust-test
runs-on: ubuntu-latest
env:
POLYGLOT_API_CONTRACT: ${{ github.workspace }}/docs/api-capabilities.json
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version: '1.25.x'
cache-dependency-path: packages/go/go.sum
- name: Go SDK unit tests
run: cd packages/go && go test ./...
- name: Verify Go SDK version matches release tag
if: startsWith(github.ref, 'refs/tags/v')
run: cd packages/go && POLYGLOT_GO_EXPECTED_VERSION="${GITHUB_REF_NAME#v}" go test ./...
- name: Download tested FFI build
uses: actions/download-artifact@v8
with:
name: rust-ci-ffi-linux-x86_64
path: target/ffi_release/
- name: Go SDK integration tests
run: cd packages/go && POLYGLOT_SQL_FFI_PATH="../../target/ffi_release/libpolyglot_sql_ffi.so" go test ./...
sdk-build:
# The fork consumes only the Rust crate and Python package.
if: github.repository == 'tobilg/polyglot'
needs: rust-test
runs-on: ubuntu-latest
env:
POLYGLOT_API_CONTRACT: ${{ github.workspace }}/docs/api-capabilities.json
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Clean WASM crate artifacts
run: cargo clean -p polyglot-sql-wasm
- name: Build WASM
run: cd packages/sdk && pnpm run build:wasm
- name: Generate TypeScript bindings
run: make generate-bindings
- name: Build SDK
run: cd packages/sdk && pnpm run build
- name: Build TypeScript API documentation
run: make documentation-build
- name: Verify SDK/WASM version matches release tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
expected_version="${GITHUB_REF_NAME#v}"
cd packages/sdk
actual_version="$(node -e "import('./dist/index.node.js').then((m) => process.stdout.write(m.getVersion()))")"
if [ "$actual_version" != "$expected_version" ]; then
echo "Version mismatch: tag=$expected_version sdk/wasm=$actual_version"
exit 1
fi
- name: Test SDK bundler integration
run: cd packages/sdk && pnpm run test:bundlers
- name: Typecheck SDK
run: cd packages/sdk && pnpm typecheck
- name: Test SDK with coverage
run: cd packages/sdk && pnpm run test:coverage
- name: Publish SDK coverage summary
if: ${{ always() && hashFiles('packages/sdk/coverage/coverage-summary.json') != '' }}
run: cd packages/sdk && pnpm run coverage:summary >> "$GITHUB_STEP_SUMMARY"
- name: Upload SDK coverage report
if: always()
uses: actions/upload-artifact@v7
with:
name: sdk-coverage
path: packages/sdk/coverage/
if-no-files-found: warn
retention-days: 14
- name: Upload WASM artifact
uses: actions/upload-artifact@v7
with:
name: wasm
path: packages/sdk/wasm/
- name: Upload SDK dist artifact
uses: actions/upload-artifact@v7
with:
name: dist
path: packages/sdk/dist/
- name: Upload SDK generated bindings artifact
uses: actions/upload-artifact@v7
with:
name: sdk-generated-bindings
path: packages/sdk/src/generated/
python-wheels-linux:
if: startsWith(github.ref, 'refs/tags/v')
needs: [rust-test, python-fast-check]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v7
- name: Build Python wheels (Linux ${{ matrix.target }})
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: '2014'
args: --profile python_release --out dist --find-interpreter --manifest-path crates/polyglot-sql-python/Cargo.toml
sccache: true
- name: Smoke test built wheel (Linux x86_64)
if: matrix.target == 'x86_64'
run: |
python -m pip install --upgrade pip
python -m pip install --no-index --find-links dist "polyglot-sql==${GITHUB_REF_NAME#v}"
python -c "import polyglot_sql; assert polyglot_sql.transpile('SELECT 1', read='postgres', write='postgres') == ['SELECT 1']"
- name: Upload wheel artifacts (Linux ${{ matrix.target }})
uses: actions/upload-artifact@v7
with:
name: python-wheels-linux-${{ matrix.target }}
path: dist
python-wheels-macos:
if: startsWith(github.ref, 'refs/tags/v')
needs: [rust-test, python-fast-check]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
runner: macos-15-intel
- target: aarch64-apple-darwin
runner: macos-15
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
# Cache failures must not interrupt the multi-interpreter wheel build.
- name: Cache macOS Rust build artifacts
uses: Swatinem/rust-cache@v2
continue-on-error: true
with:
key: python-wheels-macos-${{ matrix.target }}
cache-workspace-crates: true
- name: Build Python wheels (macOS ${{ matrix.target }})
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --profile python_release --out dist --find-interpreter --manifest-path crates/polyglot-sql-python/Cargo.toml
# sccache's remote-cache startup errors do not fall back to rustc.
sccache: false
- name: Smoke test built wheel (macOS)
run: |
python -m pip install --upgrade pip
python -m pip install --no-index --find-links dist "polyglot-sql==${GITHUB_REF_NAME#v}"
python -c "import polyglot_sql; assert polyglot_sql.parse_one('SELECT 1', dialect='postgres')"
- name: Upload wheel artifacts (macOS ${{ matrix.target }})
uses: actions/upload-artifact@v7
with:
name: python-wheels-macos-${{ matrix.target }}
path: dist
python-wheels-windows:
if: startsWith(github.ref, 'refs/tags/v')
needs: [rust-test, python-fast-check]
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- name: Build Python wheels (Windows x86_64)
uses: PyO3/maturin-action@v1
env:
SCCACHE_IGNORE_SERVER_IO_ERROR: "1"
with:
target: x86_64-pc-windows-msvc
args: --profile python_release --out dist --find-interpreter --manifest-path crates/polyglot-sql-python/Cargo.toml
sccache: true
- name: Smoke test built wheel (Windows)
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install --no-index --find-links dist "polyglot-sql==$($env:GITHUB_REF_NAME.Substring(1))"
python -c "import polyglot_sql; assert polyglot_sql.dialects()"
- name: Upload wheel artifacts (Windows x86_64)
uses: actions/upload-artifact@v7
with:
name: python-wheels-windows-x86_64
path: dist
python-sdist:
if: startsWith(github.ref, 'refs/tags/v')
needs: [rust-test, python-fast-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Build Python source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path crates/polyglot-sql-python/Cargo.toml
- name: Upload sdist artifact
uses: actions/upload-artifact@v7
with:
name: python-wheels-sdist
path: dist
publish-pypi:
if: startsWith(github.ref, 'refs/tags/v')
needs: [python-wheels-linux, python-wheels-macos, python-wheels-windows, python-sdist]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: pypi
url: https://pypi.org/p/polyglot-sql
steps:
- uses: actions/checkout@v7
- name: Download Python distribution artifacts
uses: actions/download-artifact@v8
with:
pattern: python-wheels-*
merge-multiple: true
path: dist
- name: Verify version consistency (tag, workspace, artifacts)
run: |
expected_version="${GITHUB_REF_NAME#v}"
workspace_version="$(awk '
$0 ~ /^\[workspace\.package\]/ { in_ws=1; next }
in_ws && $0 ~ /^version[[:space:]]*=/ {
line=$0;
gsub(/"/, "", line);
sub(/^.*=[[:space:]]*/, "", line);
print line;
exit;
}
' Cargo.toml)"
if [ "$workspace_version" != "$expected_version" ]; then
echo "Workspace version mismatch: expected=$expected_version actual=$workspace_version"
exit 1
fi
python - <<'PY'
import glob
import os
import re
import sys
expected = os.environ["GITHUB_REF_NAME"][1:]
files = glob.glob("dist/*")
if not files:
print("No dist artifacts found")
sys.exit(1)
wheel_re = re.compile(r"polyglot_sql-([^-]+)-.+\.whl$")
sdist_re = re.compile(r"polyglot_sql-([0-9A-Za-z.+_]+)\.tar\.gz$")
bad = []
for path in files:
name = os.path.basename(path)
if name.endswith(".whl"):
m = wheel_re.fullmatch(name)
elif name.endswith(".tar.gz"):
m = sdist_re.fullmatch(name)
else:
continue
if not m or m.group(1) != expected:
bad.append(name)
if bad:
print("Version mismatch in artifacts:", bad)
sys.exit(1)
print(f"Artifacts match expected version {expected}")
PY
- name: Smoke install from built artifacts (Linux)
run: |
expected_version="${GITHUB_REF_NAME#v}"
python -m pip install --upgrade pip
python -m pip install --no-index --find-links dist "polyglot-sql==${expected_version}"
python - <<'PY'
import os
import polyglot_sql
expected = os.environ["GITHUB_REF_NAME"][1:]
assert polyglot_sql.__version__ == expected, (polyglot_sql.__version__, expected)
assert polyglot_sql.transpile("SELECT 1", read="postgres", write="postgres") == ["SELECT 1"]
PY
- name: Publish Python package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-crate:
if: startsWith(github.ref, 'refs/tags/v')
needs: sdk-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Publish dependency crates to crates.io
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
crates=(
"polyglot-sql-ast-derive"
"polyglot-sql-function-catalogs"
)
for crate in "${crates[@]}"; do
if ./scripts/check-crate-version.sh "$crate" "$version"; then
echo "${crate} ${version} already present on crates.io"
else
cargo publish -p "$crate"
fi
done
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Wait for dependency crates index availability
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
crates=(
"polyglot-sql-ast-derive"
"polyglot-sql-function-catalogs"
)
for crate in "${crates[@]}"; do
available=false
for attempt in $(seq 1 30); do
if ./scripts/check-crate-version.sh "$crate" "$version"; then
echo "${crate} ${version} is available on crates.io"
available=true
break
fi
echo "Waiting for ${crate} ${version} to appear on crates.io (attempt ${attempt}/30)"
sleep 10
done
if [[ "$available" != true ]]; then
echo "Timed out waiting for ${crate} ${version} to appear on crates.io"
exit 1
fi
done
- name: Publish main crate to crates.io
run: |
set -euo pipefail
crate="polyglot-sql"
version="${GITHUB_REF_NAME#v}"
if ./scripts/check-crate-version.sh "$crate" "$version"; then
echo "${crate} ${version} already present on crates.io"
else
cargo publish -p "$crate"
fi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-npm:
if: startsWith(github.ref, 'refs/tags/v')
needs: sdk-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Download WASM artifact
uses: actions/download-artifact@v8
with:
name: wasm
path: packages/sdk/wasm/
- name: Download SDK dist artifact
uses: actions/download-artifact@v8
with:
name: dist
path: packages/sdk/dist/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Publish to npm
run: cd packages/sdk && pnpm publish --access public --no-git-checks --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
ffi-build-artifacts:
if: startsWith(github.ref, 'refs/tags/v')
needs: rust-test
name: Build FFI (${{ matrix.archive_name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive_name: linux-x86_64
archive_ext: tar.gz
shared_lib: libpolyglot_sql_ffi.so
static_lib: libpolyglot_sql_ffi.a
use_cross: false
target_dir: target
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive_name: linux-aarch64
archive_ext: tar.gz
shared_lib: libpolyglot_sql_ffi.so
static_lib: libpolyglot_sql_ffi.a
use_cross: true
target_dir: target-cross
- os: macos-15-intel
target: x86_64-apple-darwin
archive_name: macos-x86_64
archive_ext: tar.gz
shared_lib: libpolyglot_sql_ffi.dylib
static_lib: libpolyglot_sql_ffi.a
use_cross: false
target_dir: target
- os: macos-15
target: aarch64-apple-darwin
archive_name: macos-aarch64
archive_ext: tar.gz
shared_lib: libpolyglot_sql_ffi.dylib
static_lib: libpolyglot_sql_ffi.a
use_cross: false
target_dir: target
- os: windows-latest
target: x86_64-pc-windows-msvc
archive_name: windows-x86_64
archive_ext: zip
shared_lib: polyglot_sql_ffi.dll
static_lib: polyglot_sql_ffi.lib
use_cross: false
target_dir: target
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
if: ${{ !matrix.use_cross }}
- name: Install cross (linux aarch64)
if: matrix.use_cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build FFI artifacts with cross
if: matrix.use_cross
env:
CARGO_TARGET_DIR: ${{ matrix.target_dir }}
run: cross build -p polyglot-sql-ffi --profile ffi_release --target ${{ matrix.target }}
- name: Build FFI artifacts with cargo
if: ${{ !matrix.use_cross }}
env:
CARGO_TARGET_DIR: ${{ matrix.target_dir }}
run: cargo build -p polyglot-sql-ffi --profile ffi_release --target ${{ matrix.target }}
- name: Package archive (unix)
if: runner.os != 'Windows'
run: |
dir="polyglot-sql-ffi-${{ matrix.archive_name }}"
mkdir -p "$dir"
cp crates/polyglot-sql-ffi/polyglot_sql.h "$dir/"
cp "${{ matrix.target_dir }}/${{ matrix.target }}/ffi_release/${{ matrix.shared_lib }}" "$dir/"
cp "${{ matrix.target_dir }}/${{ matrix.target }}/ffi_release/${{ matrix.static_lib }}" "$dir/"
cp LICENSE "$dir/"
tar -czf "${dir}.tar.gz" "$dir"
- name: Package archive (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$dir = "polyglot-sql-ffi-${{ matrix.archive_name }}"
New-Item -ItemType Directory -Path $dir -Force | Out-Null
Copy-Item "crates/polyglot-sql-ffi/polyglot_sql.h" "$dir/"
Copy-Item "${{ matrix.target_dir }}/${{ matrix.target }}/ffi_release/${{ matrix.shared_lib }}" "$dir/"
Copy-Item "${{ matrix.target_dir }}/${{ matrix.target }}/ffi_release/${{ matrix.static_lib }}" "$dir/"
Copy-Item "LICENSE" "$dir/"
Compress-Archive -Path $dir -DestinationPath "$dir.zip" -Force
- name: Upload archive artifact
uses: actions/upload-artifact@v7
with:
name: ffi-${{ matrix.archive_name }}
path: polyglot-sql-ffi-${{ matrix.archive_name }}.${{ matrix.archive_ext }}
publish-ffi-assets:
if: startsWith(github.ref, 'refs/tags/v')
needs: [ffi-build-artifacts, go-sdk-release-artifact]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all FFI archives
uses: actions/download-artifact@v8
with:
pattern: ffi-*
path: dist
merge-multiple: true
- name: Generate checksums
run: |
cd dist
shopt -s nullglob
files=(*.tar.gz *.zip)
if [ ${#files[@]} -eq 0 ]; then
echo "No FFI archives found"
exit 1
fi
sha256sum "${files[@]}" > checksums.sha256
- name: Attach assets to GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.sha256
go-sdk-release-artifact:
if: startsWith(github.ref, 'refs/tags/v')
needs: [ffi-build-artifacts]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version: '1.25.x'
cache-dependency-path: packages/go/go.sum
- name: Download Linux x86_64 FFI archive
uses: actions/download-artifact@v8
with:
name: ffi-linux-x86_64
path: dist
- name: Test Go SDK against release-built FFI artifact
run: |
tar -xzf dist/polyglot-sql-ffi-linux-x86_64.tar.gz -C dist
cd packages/go
POLYGLOT_SQL_FFI_PATH="../../dist/polyglot-sql-ffi-linux-x86_64/libpolyglot_sql_ffi.so" go test ./...
tag-go-module:
if: startsWith(github.ref, 'refs/tags/v')
needs: [go-sdk-release-artifact]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Create matching Go module tag
run: |
set -euo pipefail
tag="packages/go/${GITHUB_REF_NAME}"
if git ls-remote --exit-code --tags origin "refs/tags/${tag}" >/dev/null 2>&1; then
echo "${tag} already exists"
exit 0
fi
git tag "${tag}" HEAD
git push origin "refs/tags/${tag}"
deploy-docs:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish-crate, publish-npm]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Download WASM artifact
uses: actions/download-artifact@v8
with:
name: wasm
path: packages/sdk/wasm/
- name: Download SDK generated bindings artifact
uses: actions/download-artifact@v8
with:
name: sdk-generated-bindings
path: packages/sdk/src/generated/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build documentation
run: cd packages/documentation && pnpm run build
- name: Verify docs version matches release tag
run: |
expected_version="${GITHUB_REF_NAME#v}"
if ! grep -Fq "v${expected_version}" packages/documentation/dist/modules.html; then
echo "Documentation version mismatch: expected v${expected_version}"
exit 1
fi
- name: Validate Cloudflare credentials
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
test -n "$CLOUDFLARE_API_TOKEN" || { echo "Missing CLOUDFLARE_API_TOKEN"; exit 1; }
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "Missing CLOUDFLARE_ACCOUNT_ID"; exit 1; }
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/documentation
command: pages deploy dist --project-name=polyglot-sql-api --branch main
deploy-python-docs:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish-pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build Python API documentation
run: |
cd crates/polyglot-sql-python
uv run --with mkdocs mkdocs build --strict --clean --config-file mkdocs.yml --site-dir ../../packages/python-docs/dist
- name: Verify generated documentation
run: |
test -f packages/python-docs/dist/index.html || { echo "Missing packages/python-docs/dist/index.html"; exit 1; }
- name: Validate Cloudflare credentials
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
test -n "$CLOUDFLARE_API_TOKEN" || { echo "Missing CLOUDFLARE_API_TOKEN"; exit 1; }
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "Missing CLOUDFLARE_ACCOUNT_ID"; exit 1; }
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/python-docs
command: pages deploy dist --project-name=polyglot-sql-python-api --branch main
deploy-playground:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish-crate, publish-npm]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/setup@v3
with:
version: 12.4.2
install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Download WASM artifact
uses: actions/download-artifact@v8
with:
name: wasm
path: packages/sdk/wasm/
- name: Download SDK dist artifact
uses: actions/download-artifact@v8
with:
name: dist
path: packages/sdk/dist/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Playground
run: cd packages/playground && pnpm run build
- name: Verify playground SDK/WASM version matches release tag
run: |
expected_version="${GITHUB_REF_NAME#v}"
actual_version="$(node -e "const fs=require('node:fs'); const p=JSON.parse(fs.readFileSync('packages/sdk/wasm/package.json','utf8')); process.stdout.write(p.version);")"
if [ "$actual_version" != "$expected_version" ]; then
echo "Playground SDK/WASM version mismatch: expected=$expected_version actual=$actual_version"
exit 1
fi
- name: Validate Cloudflare credentials
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
test -n "$CLOUDFLARE_API_TOKEN" || { echo "Missing CLOUDFLARE_API_TOKEN"; exit 1; }
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "Missing CLOUDFLARE_ACCOUNT_ID"; exit 1; }
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/playground
command: pages deploy dist --project-name=polyglot-sql-playground --branch main