name: Build Python release candidates
on:
workflow_call:
inputs:
release_ref:
required: true
type: string
workflow_dispatch:
inputs:
release_ref:
description: Exact annotated lockstep tag to build and test (vX.Y.Z)
required: true
type: string
concurrency:
group: release-python-${{ inputs.release_ref }}
cancel-in-progress: false
jobs:
build:
name: manylinux wheels
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.release_ref }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@1.95.0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: verify tag and package version
env:
RELEASE_REF: ${{ inputs.release_ref }}
run: |
test "$(git describe --tags --exact-match HEAD)" = "$RELEASE_REF"
test "$(git cat-file -t "$RELEASE_REF")" = tag
test "v$(python -c 'import tomllib; print(tomllib.load(open("bindings/python/pyproject.toml", "rb"))["project"]["version"])')" = "$RELEASE_REF"
- uses: PyO3/maturin-action@v1
with:
target: x86_64
manylinux: auto
args: >-
--manifest-path bindings/python/Cargo.toml
--release --out dist
--interpreter python3.9 python3.10 python3.11 python3.12 python3.13
sccache: true
- name: record exact wheel digests
run: |
version="${RELEASE_REF#v}"
python scripts/release-artifacts.py create --component python-manylinux \
--version "$version" --output dist/python-manifest-manylinux.json dist/*.whl
env:
RELEASE_REF: ${{ inputs.release_ref }}
- uses: actions/upload-artifact@v7
with:
name: turndb-python-wheels-${{ inputs.release_ref }}
path: dist/*.whl
if-no-files-found: error
- uses: actions/upload-artifact@v7
with:
name: release-digests-python-manylinux-${{ inputs.release_ref }}
path: dist/python-manifest-manylinux.json
if-no-files-found: error
windows:
name: Windows wheel (Python ${{ matrix.python }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.release_ref }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@1.95.0
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: verify tag, package version and actual interpreter
shell: bash
env:
RELEASE_REF: ${{ inputs.release_ref }}
run: |
test "$(git describe --tags --exact-match HEAD)" = "$RELEASE_REF"
test "$(git cat-file -t "$RELEASE_REF")" = tag
mapfile -t versions < <(sed -n 's/^version = "\([^"]*\)"$/\1/p' bindings/python/pyproject.toml)
test "${#versions[@]}" -eq 1
test "v${versions[0]}" = "$RELEASE_REF"
python -c "import platform; assert platform.python_version().startswith('${{ matrix.python }}.')"
python -c "import hashlib,pathlib,platform,sys,sysconfig; p=pathlib.Path(sys.executable); print(platform.python_version(), p, hashlib.sha256(p.read_bytes()).hexdigest(), sysconfig.get_config_var('EXT_SUFFIX'))"
- run: python -m pip install 'maturin>=1.7,<2'
- name: build exact Windows wheel
run: >-
maturin build --manifest-path bindings/python/Cargo.toml
--release --out dist --interpreter python
- name: record exact wheel digest
shell: pwsh
run: |
$version = '${{ inputs.release_ref }}'.Substring(1)
$wheels = @(Get-ChildItem dist -Filter '*.whl')
if ($wheels.Count -ne 1) { throw "expected one wheel, got $($wheels.Count)" }
python scripts/release-artifacts.py create --component "python-windows-${{ matrix.python }}" `
--version $version --output "python-manifest-${{ matrix.python }}.json" $wheels[0].FullName
- uses: actions/upload-artifact@v7
with:
name: turndb-python-windows-${{ matrix.python }}-${{ inputs.release_ref }}
path: dist/*.whl
if-no-files-found: error
- uses: actions/upload-artifact@v7
with:
name: release-digests-python-windows-${{ matrix.python }}-${{ inputs.release_ref }}
path: python-manifest-${{ matrix.python }}.json
if-no-files-found: error
sdist:
name: source distribution
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.release_ref }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@1.95.0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- run: python -m pip install 'maturin>=1.7,<2'
- run: maturin sdist --manifest-path bindings/python/Cargo.toml --out dist
- uses: actions/upload-artifact@v7
with:
name: turndb-python-sdist-${{ inputs.release_ref }}
path: dist/*.tar.gz
if-no-files-found: error
install:
name: install ${{ matrix.platform }} wheel (Python ${{ matrix.python }})
needs: [build, windows]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
platform: [manylinux, windows]
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
include:
- platform: manylinux
runner: ubuntu-22.04
- platform: windows
runner: windows-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.release_ref }}
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@v4
if: matrix.platform == 'manylinux'
with:
name: turndb-python-wheels-${{ inputs.release_ref }}
path: dist
- uses: actions/download-artifact@v4
if: matrix.platform == 'manylinux'
with:
name: release-digests-python-manylinux-${{ inputs.release_ref }}
path: manifests
- uses: actions/download-artifact@v4
if: matrix.platform == 'windows'
with:
name: turndb-python-windows-${{ matrix.python }}-${{ inputs.release_ref }}
path: dist
- uses: actions/download-artifact@v4
if: matrix.platform == 'windows'
with:
name: release-digests-python-windows-${{ matrix.python }}-${{ inputs.release_ref }}
path: manifests
- name: reassert build digests before install
shell: pwsh
run: |
$manifests = @(Get-ChildItem manifests -Filter '*.json')
if ($manifests.Count -ne 1) { throw "expected one digest manifest, got $($manifests.Count)" }
python scripts/release-artifacts.py verify --manifest $manifests[0].FullName --directory dist
- name: install and exercise exact manylinux wheel
if: matrix.platform == 'manylinux'
shell: bash
run: |
python -m pip install 'opentelemetry-sdk>=1.20,<2'
python -m pip install --no-index --find-links dist turndb
python - <<'PY'
import tempfile
from opentelemetry.sdk.trace import TracerProvider
import turndb
with tempfile.TemporaryDirectory() as root:
store = turndb.Store.open(root + "/smoke.turndb")
store.write([{"kind": "put", "id": "smoke", "attrs": [], "contents": []}], durable=True)
assert [row["id"] for row in store.scan({"contractVersion": 1, "limit": 10})["rows"]] == ["smoke"]
store.close(durable=True)
tracer = TracerProvider().get_tracer("turndb-wheel")
assert turndb.trace_gen_ai_call(tracer, lambda: 7, operation_name="chat") == 7
PY
- name: install and exercise exact Windows wheel
if: matrix.platform == 'windows'
shell: pwsh
run: |
$version = '${{ inputs.release_ref }}'.Substring(1)
$wheels = @(Get-ChildItem dist -Filter '*.whl')
if ($wheels.Count -ne 1) { throw "expected one wheel, got $($wheels.Count)" }
scripts/test-wheel-local-index.ps1 -Wheel $wheels[0].FullName -Version $version `
-WorkDirectory "$env:RUNNER_TEMP/release-wheel-${{ matrix.python }}"