ci: add GitHub Actions CI/CD for v0.6.5 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Wheels | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version (e.g. 0.6.5)" | ||
| required: true | ||
| type: string | ||
| dry_run: | ||
| description: "Build only, don't publish" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| release: | ||
| types: [published] | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| jobs: | ||
| build-wheels: | ||
| name: Build Wheels (${{ matrix.os }}, ${{ matrix.target }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| python: "3.12" | ||
| manylinux: manylinux_2_28_x86_64 | ||
| - os: ubuntu-latest | ||
| target: aarch64-unknown-linux-gnu | ||
| python: "3.12" | ||
| manylinux: manylinux_2_28_aarch64 | ||
| - os: macos-latest | ||
| target: universal2-apple-darwin | ||
| python: "3.12" | ||
| manylinux: "" | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| python: "3.12" | ||
| manylinux: "" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| target: ${{ matrix.target }} | ||
| - name: Set up Python ${{ matrix.python }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| - name: Cache cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin | ||
| ~/.cargo/registry/index | ||
| ~/.cargo/registry/cache | ||
| target | ||
| key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} | ||
| - name: Install maturin | ||
| run: pip install maturin | ||
| - name: Build wheel | ||
| id: build | ||
| run: | | ||
| maturin build --release --strip --target ${{ matrix.target }} --out dist/ | ||
| env: | ||
| RUSTFLAGS: -C target-cpu=native | ||
| - name: Verify wheel | ||
| run: | | ||
| ls -la dist/ | ||
| python -m pip install dist/*.whl | ||
| python -c " | ||
| import qector_decoder_v3 as qd | ||
| print('Version:', qd.__version__) | ||
| print('FastUF:', hasattr(qd, 'FastUnionFindDecoder')) | ||
| print('Blossom:', hasattr(qd, 'BlossomDecoder')) | ||
| print('Batch:', hasattr(qd, 'BatchDecoder')) | ||
| print('CUDA:', hasattr(qd, 'CUDABatchDecoder')) | ||
| print('OpenCL:', hasattr(qd, 'OpenCLBatchDecoder')) | ||
| print('gRPC:', hasattr(qd, 'run_grpc_server')) | ||
| print('MCP:', hasattr(qd, 'run_mcp_server')) | ||
| " | ||
| shell: bash | ||
| - name: Test wheel in clean venv | ||
| run: | | ||
| python -m venv .venv_test | ||
| .venv_test/bin/pip install dist/*.whl | ||
| .venv_test/bin/python -c " | ||
| import qector_decoder_v3 as qd | ||
| import numpy as np | ||
| # Test core decoders | ||
| dec = qd.FastUnionFindDecoder([[0,1]], 2) | ||
| corr = dec.decode(np.array([1], dtype=np.uint8)) | ||
| print('FastUF decode:', corr) | ||
| # Test Blossom | ||
| dec2 = qd.BlossomDecoder([[0,1,2,3]], 4) | ||
| corr2 = dec2.decode(np.array([1], dtype=np.uint8)) | ||
| print('Blossom decode:', corr2) | ||
| # Test Batch | ||
| dec3 = qd.BatchDecoder([[0,1]], 2) | ||
| corr3 = dec3.batch_decode(np.array([[1]], dtype=np.uint8)) | ||
| print('Batch decode:', corr3) | ||
| print('All decoder tests passed') | ||
| " | ||
| shell: bash | ||
| - name: Upload wheel artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-${{ matrix.os }}-${{ matrix.target }} | ||
| path: dist/*.whl | ||
| retention-days: 7 | ||
| publish: | ||
| name: Publish to PyPI | ||
| needs: build-wheels | ||
| if: github.event.inputs.dry_run != 'true' || github.event_name == 'release' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Download all wheels | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: wheels-* | ||
| path: dist/ | ||
| merge-multiple: true | ||
| - name: Verify wheels | ||
| run: | | ||
| ls -la dist/ | ||
| pip install twine | ||
| twine check dist/* | ||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: dist/ | ||
| verbose: true | ||
| tag-version: | ||
| name: Tag Version | ||
| needs: build-wheels | ||
| if: github.event.inputs.dry_run != 'true' && github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Configure git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| - name: Create and push tag | ||
| env: | ||
| VERSION: ${{ github.event.inputs.version }} | ||
| run: | | ||
| git tag -a v${VERSION} -m "Release v${VERSION}" | ||
| git push origin v${VERSION} | ||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: v${{ github.event.inputs.version }} | ||
| generate_release_notes: true | ||
| files: dist/*.whl | ||