llmshim 0.1.26

Blazing fast LLM API translation layer in pure Rust
Documentation
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
name: Release

on:
  push:
    tags:
      - "v*"

env:
  PYTHON_VERSION: "3.12"

jobs:
  # --- Run tests first ---
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Check formatting
        run: cargo fmt --check
      - name: Clippy
        run: cargo clippy --features proxy -- -D warnings
      - name: Unit tests
        run: cargo test --features proxy --tests

  # --- Publish to crates.io ---
  crates-io:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        # Idempotent: treat "already uploaded" as success so re-running the
        # release (e.g. to fill a failed downstream registry) is safe.
        run: |
          set +e
          out=$(cargo publish --allow-dirty 2>&1); code=$?
          echo "$out"
          [ $code -eq 0 ] && exit 0
          echo "$out" | grep -qiE "already (been )?uploaded|already exists" \
            && { echo "Version already on crates.io; skipping."; exit 0; }
          exit $code

  # --- Build standalone macOS binaries + GitHub release ---
  github-release:
    needs: test
    runs-on: macos-14
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-apple-darwin,x86_64-apple-darwin
      - name: Build arm64
        run: cargo build --release --features proxy --target aarch64-apple-darwin
      - name: Build x86_64
        run: cargo build --release --features proxy --target x86_64-apple-darwin
      - name: Package tarballs
        run: |
          for target in aarch64-apple-darwin x86_64-apple-darwin; do
            mkdir -p staging
            cp target/$target/release/llmshim staging/
            tar -czf llmshim-${target}.tar.gz -C staging llmshim
            rm -rf staging
          done
      - name: Create GitHub release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        # Idempotent: if the release already exists (re-run), (re-)upload the
        # tarballs to it instead of failing on create.
        run: |
          if gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then
            echo "Release already exists; uploading assets with --clobber."
            gh release upload "${{ github.ref_name }}" \
              llmshim-aarch64-apple-darwin.tar.gz \
              llmshim-x86_64-apple-darwin.tar.gz --clobber
          else
            gh release create ${{ github.ref_name }} \
              --title "${{ github.ref_name }}" \
              --generate-notes \
              llmshim-aarch64-apple-darwin.tar.gz \
              llmshim-x86_64-apple-darwin.tar.gz
          fi

  # --- Update Homebrew tap ---
  homebrew:
    needs: github-release
    runs-on: macos-14
    steps:
      - name: Update Homebrew formula
        env:
          GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
        run: |
          VERSION=${GITHUB_REF_NAME#v}
          BASE_URL="https://github.com/sanjay920/llmshim/releases/download/${GITHUB_REF_NAME}"

          # Download tarballs to compute sha256
          curl -sL "${BASE_URL}/llmshim-aarch64-apple-darwin.tar.gz" -o /tmp/arm64.tar.gz
          curl -sL "${BASE_URL}/llmshim-x86_64-apple-darwin.tar.gz" -o /tmp/x86.tar.gz
          SHA_ARM=$(shasum -a 256 /tmp/arm64.tar.gz | cut -d' ' -f1)
          SHA_X86=$(shasum -a 256 /tmp/x86.tar.gz | cut -d' ' -f1)

          # Generate formula
          cat > /tmp/llmshim.rb << 'ENDOFTEMPLATE'
          class Llmshim < Formula
            desc "Blazing fast LLM API translation layer — one interface, every provider"
            homepage "https://github.com/sanjay920/llmshim"
            license "MIT"
            version "VERSION_PLACEHOLDER"

            on_macos do
              if Hardware::CPU.arm?
                url "URL_ARM_PLACEHOLDER"
                sha256 "SHA_ARM_PLACEHOLDER"
              else
                url "URL_X86_PLACEHOLDER"
                sha256 "SHA_X86_PLACEHOLDER"
              end
            end

            def install
              bin.install "llmshim"
            end

            test do
              assert_predicate bin/"llmshim", :executable?
            end
          end
          ENDOFTEMPLATE

          # Replace placeholders
          sed -i '' "s|VERSION_PLACEHOLDER|${VERSION}|g" /tmp/llmshim.rb
          sed -i '' "s|URL_ARM_PLACEHOLDER|${BASE_URL}/llmshim-aarch64-apple-darwin.tar.gz|g" /tmp/llmshim.rb
          sed -i '' "s|URL_X86_PLACEHOLDER|${BASE_URL}/llmshim-x86_64-apple-darwin.tar.gz|g" /tmp/llmshim.rb
          sed -i '' "s|SHA_ARM_PLACEHOLDER|${SHA_ARM}|g" /tmp/llmshim.rb
          sed -i '' "s|SHA_X86_PLACEHOLDER|${SHA_X86}|g" /tmp/llmshim.rb

          # Remove leading whitespace from heredoc
          sed -i '' 's/^          //' /tmp/llmshim.rb

          # Get existing file SHA (if updating)
          EXISTING_SHA=$(gh api repos/sanjay920/homebrew-tap/contents/Formula/llmshim.rb --jq .sha 2>/dev/null || echo "")

          # Push to homebrew-tap repo
          if [ -n "$EXISTING_SHA" ]; then
            gh api repos/sanjay920/homebrew-tap/contents/Formula/llmshim.rb \
              --method PUT \
              --field message="Update llmshim to ${VERSION}" \
              --field content="$(base64 -i /tmp/llmshim.rb)" \
              --field sha="${EXISTING_SHA}"
          else
            gh api repos/sanjay920/homebrew-tap/contents/Formula/llmshim.rb \
              --method PUT \
              --field message="Add llmshim ${VERSION}" \
              --field content="$(base64 -i /tmp/llmshim.rb)"
          fi

  # --- Build + publish the platform-specific npm binary packages ---
  # The TS client bundles a prebuilt binary the same way the Python client
  # does (via maturin). npm has no maturin equivalent, so this follows the
  # standard npm pattern for native binaries (esbuild, swc, turborepo): one
  # tiny package per os/cpu combo, gated by "os"/"cpu" fields, installed
  # automatically as an optionalDependency of the root `llmshim` package.
  #
  # Each of these 5 packages needs its own Trusted Publisher configured on
  # npmjs.com once (same values as the root package: repo sanjay920/llmshim,
  # workflow release.yml, environment release) — see clients/typescript/README.md.
  npm-macos-binaries:
    needs: test
    runs-on: macos-14
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-apple-darwin,x86_64-apple-darwin
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          registry-url: "https://registry.npmjs.org"
      - name: Upgrade npm (OIDC trusted publishing needs npm >= 11.5.1)
        run: npm install -g npm@latest
      - name: Verify versions match the release tag
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          for pkg in llmshim-darwin-arm64 llmshim-darwin-x64; do
            PKG_VERSION=$(node -p "require('./clients/typescript/packages/$pkg/package.json').version")
            if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
              echo "::error::$pkg version ($PKG_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
              exit 1
            fi
          done
      - name: Build arm64 + x64
        run: |
          cargo build --release --features proxy --target aarch64-apple-darwin
          cargo build --release --features proxy --target x86_64-apple-darwin
      - name: Publish llmshim-darwin-arm64
        working-directory: clients/typescript/packages/llmshim-darwin-arm64
        run: |
          mkdir -p bin && cp "$GITHUB_WORKSPACE/target/aarch64-apple-darwin/release/llmshim" bin/llmshim
          chmod +x bin/llmshim
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi
      - name: Publish llmshim-darwin-x64
        working-directory: clients/typescript/packages/llmshim-darwin-x64
        run: |
          mkdir -p bin && cp "$GITHUB_WORKSPACE/target/x86_64-apple-darwin/release/llmshim" bin/llmshim
          chmod +x bin/llmshim
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi

  npm-linux-x64-binary:
    needs: test
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-unknown-linux-gnu
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          registry-url: "https://registry.npmjs.org"
      - name: Upgrade npm (OIDC trusted publishing needs npm >= 11.5.1)
        run: npm install -g npm@latest
      - name: Verify version matches the release tag
        working-directory: clients/typescript/packages/llmshim-linux-x64
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          PKG_VERSION=$(node -p "require('./package.json').version")
          if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
            echo "::error::llmshim-linux-x64 version ($PKG_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
            exit 1
          fi
      - name: Build
        run: cargo build --release --features proxy --target x86_64-unknown-linux-gnu
      - name: Publish llmshim-linux-x64
        working-directory: clients/typescript/packages/llmshim-linux-x64
        run: |
          mkdir -p bin && cp $GITHUB_WORKSPACE/target/x86_64-unknown-linux-gnu/release/llmshim bin/llmshim
          chmod +x bin/llmshim
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi

  # Native arm64 runner (GA, free on public repos) — no cross-compilation needed.
  npm-linux-arm64-binary:
    needs: test
    runs-on: ubuntu-24.04-arm
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-unknown-linux-gnu
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          registry-url: "https://registry.npmjs.org"
      - name: Upgrade npm (OIDC trusted publishing needs npm >= 11.5.1)
        run: npm install -g npm@latest
      - name: Verify version matches the release tag
        working-directory: clients/typescript/packages/llmshim-linux-arm64
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          PKG_VERSION=$(node -p "require('./package.json').version")
          if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
            echo "::error::llmshim-linux-arm64 version ($PKG_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
            exit 1
          fi
      - name: Build
        run: cargo build --release --features proxy --target aarch64-unknown-linux-gnu
      - name: Publish llmshim-linux-arm64
        working-directory: clients/typescript/packages/llmshim-linux-arm64
        run: |
          mkdir -p bin && cp $GITHUB_WORKSPACE/target/aarch64-unknown-linux-gnu/release/llmshim bin/llmshim
          chmod +x bin/llmshim
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi

  npm-windows-binary:
    needs: test
    runs-on: windows-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-msvc
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          registry-url: "https://registry.npmjs.org"
      - name: Upgrade npm (OIDC trusted publishing needs npm >= 11.5.1)
        shell: bash
        run: npm install -g npm@latest
      - name: Verify version matches the release tag
        shell: bash
        working-directory: clients/typescript/packages/llmshim-win32-x64
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          PKG_VERSION=$(node -p "require('./package.json').version")
          if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
            echo "::error::llmshim-win32-x64 version ($PKG_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
            exit 1
          fi
      - name: Build
        shell: bash
        run: cargo build --release --features proxy --target x86_64-pc-windows-msvc
      - name: Publish llmshim-win32-x64
        shell: bash
        working-directory: clients/typescript/packages/llmshim-win32-x64
        run: |
          mkdir -p bin && cp "$GITHUB_WORKSPACE/target/x86_64-pc-windows-msvc/release/llmshim.exe" bin/llmshim.exe
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi

  # --- Publish TypeScript client to npm ---
  # First release must be published manually once (npm's trusted-publisher UI
  # requires the package to already exist); every release after that publishes
  # here via OIDC, no token stored. See clients/typescript/README.md. Depends
  # on the binary packages above so `optionalDependencies` resolve to a real,
  # already-published version by the time this installs/publishes.
  npm:
    needs:
      - test
      - npm-macos-binaries
      - npm-linux-x64-binary
      - npm-linux-arm64-binary
      - npm-windows-binary
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    defaults:
      run:
        working-directory: clients/typescript
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          registry-url: "https://registry.npmjs.org"
      - name: Upgrade npm (OIDC trusted publishing needs npm >= 11.5.1)
        run: npm install -g npm@latest
      - name: Verify package.json version matches the release tag
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          PKG_VERSION=$(node -p "require('./package.json').version")
          if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
            echo "::error::clients/typescript/package.json version ($PKG_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
            exit 1
          fi
      # Only devDeps (typescript) are needed to build/publish. Skip the
      # optional platform packages — they publish in this same run, so the
      # lockfile can't reference their new version yet, and `npm ci`'s strict
      # sync check would fail. They're end-user runtime deps, not build deps.
      - run: npm install --omit=optional --no-audit --no-fund
      - run: npm run build
      - run: npm test
      - name: Publish to npm
        run: |
          NAME=$(node -p "require('./package.json').name"); VER=$(node -p "require('./package.json').version")
          if npm view "$NAME@$VER" version >/dev/null 2>&1; then
            echo "$NAME@$VER already on npm; skipping."
          else
            npm publish --access public --provenance
          fi

  # --- Publish Ruby client to RubyGems ---
  # Uses a "pending trusted publisher" — configurable on rubygems.org before
  # the gem's first-ever release, no manual bootstrap publish needed.
  rubygems:
    needs: test
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
      contents: read
    defaults:
      run:
        working-directory: clients/ruby
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.3"
      - name: Verify version.rb matches the release tag
        run: |
          TAG_VERSION=${GITHUB_REF_NAME#v}
          GEM_VERSION=$(ruby -Ilib -e 'require "llmshim/version"; print Llmshim::VERSION')
          if [ "$TAG_VERSION" != "$GEM_VERSION" ]; then
            echo "::error::clients/ruby/lib/llmshim/version.rb ($GEM_VERSION) does not match tag ($TAG_VERSION) — bump it before releasing"
            exit 1
          fi
      # Install test-only gems explicitly (Ruby 3.0+ dropped webrick from the
      # default gems). Avoids bundler-cache serving a stale bundle when only the
      # gemspec — not the Gemfile — changes.
      - name: Run tests
        run: |
          gem install --no-document minitest webrick
          ruby -Itest -Ilib test/llmshim_test.rb
      - name: Configure RubyGems credentials (OIDC trusted publishing)
        uses: rubygems/configure-rubygems-credentials@v2.1.0
      - name: Build gem
        run: gem build llmshim.gemspec
      - name: Push gem
        run: gem push llmshim-*.gem

  # --- Tag the Go client module for a clean `go get` version ---
  # `go get github.com/sanjay920/llmshim/clients/go` already works today via
  # Go's VCS auto-fetch (no registry to publish to), but without a tag of the
  # form "clients/go/vX.Y.Z" it resolves an ugly pseudo-version. This job adds
  # that tag on every release so `go get .../clients/go@latest` resolves clean
  # semver matching the crate version.
  go-tag:
    needs: test
    runs-on: ubuntu-latest
    permissions:
      contents: write
    defaults:
      run:
        working-directory: clients/go
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "1.21"
      - name: Build, vet, and test the Go client
        run: |
          test -z "$(gofmt -l .)"
          go vet ./...
          go test ./...
      - name: Tag the Go module
        # Idempotent: skip if the module tag already exists (re-run).
        run: |
          VERSION=${GITHUB_REF_NAME#v}
          GO_TAG="clients/go/v${VERSION}"
          if git ls-remote --exit-code --tags origin "refs/tags/$GO_TAG" >/dev/null 2>&1; then
            echo "$GO_TAG already exists; skipping."
          else
            git tag "$GO_TAG"
            git push origin "$GO_TAG"
          fi

  # --- Build PyPI source distribution ---
  sdist:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist
          working-directory: clients/python
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-sdist
          path: clients/python/dist

  # --- macOS wheels (ARM64 + x86_64) ---
  macos:
    needs: test
    runs-on: macos-14
    strategy:
      matrix:
        target: [aarch64-apple-darwin, x86_64-apple-darwin]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist
          working-directory: clients/python
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-macos-${{ matrix.target }}
          path: clients/python/dist

  # --- Linux x86_64 wheel ---
  linux-x86:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          target: x86_64-unknown-linux-gnu
          manylinux: "2_17"
          args: --release --out dist
          working-directory: clients/python
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-linux-x86_64
          path: clients/python/dist

  # --- Linux aarch64 wheel (use zig for cross-compilation) ---
  linux-arm:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          target: aarch64-unknown-linux-gnu
          manylinux: "2_17"
          args: --release --out dist --zig
          working-directory: clients/python
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-linux-aarch64
          path: clients/python/dist

  # --- Windows x86_64 wheel ---
  windows:
    needs: test
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          target: x86_64-pc-windows-msvc
          args: --release --out dist
          working-directory: clients/python
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-windows-x86_64
          path: clients/python/dist

  # --- Publish to PyPI ---
  pypi:
    needs: [sdist, macos, linux-x86, linux-arm, windows]
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: wheels-*
          path: dist
          merge-multiple: true
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist/
          # Idempotent: don't fail if this version is already on PyPI (re-run).
          skip-existing: true