Introduce None sentinel for input_bounds in n_bits calibration #158
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: Build and Publish to PyPI | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build-linux: | |
| if: >- | |
| github.event_name != 'pull_request' || | |
| contains(github.event.pull_request.labels.*.name, 'test-build') | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| container: | |
| image: quay.io/pypa/manylinux_2_28_x86_64 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install system dependencies | |
| run: | | |
| dnf install -y pkgconf-pkg-config perl-IPC-Cmd perl-Time-Piece clang-devel | |
| - name: Install Rust | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Extract version | |
| id: get_version | |
| shell: bash | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/') | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "version_underscore=$(echo $VERSION | tr '.' '-')" >> $GITHUB_OUTPUT | |
| - name: Update pyproject.toml version | |
| run: | | |
| sed -i 's/version = ".*"/version = "${{ steps.get_version.outputs.version }}"/' pyproject.toml | |
| sed -i 's/onnx_generic_circuit_[0-9-]*/onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}/' pyproject.toml | |
| - name: Update Cargo.toml version | |
| run: | | |
| sed -i '0,/^version = ".*"/{s/^version = ".*"/version = "${{ steps.get_version.outputs.version }}"/}' rust/jstprove_circuits/Cargo.toml | |
| sed -i 's/name = "onnx_generic_circuit_.*"/name = "onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}"/' rust/jstprove_circuits/Cargo.toml | |
| - name: Install Rust target | |
| run: rustup target add x86_64-unknown-linux-gnu | |
| - name: Cache cargo registry | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/registry | |
| key: manylinux-2-28-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/git | |
| key: manylinux-2-28-cargo-git-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v5 | |
| with: | |
| path: target | |
| key: manylinux-2-28-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build Rust binaries | |
| run: cargo build --release --target x86_64-unknown-linux-gnu --bin onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }} | |
| - name: Collect binaries | |
| shell: bash | |
| run: | | |
| BINARY_NAME="onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}" | |
| MAIN_BIN="target/x86_64-unknown-linux-gnu/release/${BINARY_NAME}" | |
| BIN_DIR="python/core/binaries" | |
| mkdir -p "$BIN_DIR" | |
| cp "$MAIN_BIN" "$BIN_DIR/" | |
| chmod +x "$BIN_DIR/$BINARY_NAME" | |
| - name: Build wheel | |
| run: uv build | |
| - name: Retag wheel with platform | |
| run: | | |
| uv tool install wheel | |
| uvx wheel tags --platform-tag=manylinux_2_28_x86_64 --remove dist/*.whl | |
| - name: Test wheel installation | |
| run: | | |
| WHEEL=$(ls dist/*.whl) | |
| uv tool install "$WHEEL" | |
| export PATH="$HOME/.local/bin:$PATH" | |
| jst compile -m python/models/models_onnx/lenet.onnx -c ./test_circuit.txt | |
| if [ ! -f ./test_circuit.txt ]; then | |
| echo "Error: Circuit file was not created" | |
| exit 1 | |
| fi | |
| echo "Wheel test passed" | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: wheel-ubuntu-x86_64 | |
| path: ./dist/*.whl | |
| build-macos: | |
| if: >- | |
| github.event_name != 'pull_request' || | |
| contains(github.event.pull_request.labels.*.name, 'test-build') | |
| runs-on: macos-latest | |
| timeout-minutes: 60 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Extract version | |
| id: get_version | |
| shell: bash | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/') | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "version_underscore=$(echo $VERSION | tr '.' '-')" >> $GITHUB_OUTPUT | |
| - name: Update pyproject.toml version | |
| run: | | |
| sed -i '' 's/version = ".*"/version = "${{ steps.get_version.outputs.version }}"/' pyproject.toml | |
| sed -i '' 's/onnx_generic_circuit_[0-9-]*/onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}/' pyproject.toml | |
| - name: Update Cargo.toml version | |
| run: | | |
| sed -i '' '1,/^version = /{s/^version = ".*"/version = "${{ steps.get_version.outputs.version }}"/;}' rust/jstprove_circuits/Cargo.toml | |
| sed -i '' 's/name = "onnx_generic_circuit_.*"/name = "onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}"/' rust/jstprove_circuits/Cargo.toml | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install Rust target | |
| run: rustup target add aarch64-apple-darwin | |
| - name: Cache cargo registry | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/registry | |
| key: macos-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/git | |
| key: macos-cargo-git-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v5 | |
| with: | |
| path: target | |
| key: macos-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build Rust binaries | |
| run: cargo build --release --target aarch64-apple-darwin --bin onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }} | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: "11.0" | |
| - name: Collect binaries | |
| shell: bash | |
| run: | | |
| BINARY_NAME="onnx_generic_circuit_${{ steps.get_version.outputs.version_underscore }}" | |
| MAIN_BIN="target/aarch64-apple-darwin/release/${BINARY_NAME}" | |
| BIN_DIR="python/core/binaries" | |
| mkdir -p "$BIN_DIR" | |
| cp "$MAIN_BIN" "$BIN_DIR/" | |
| chmod +x "$BIN_DIR/$BINARY_NAME" | |
| - name: Build wheel | |
| run: uv build | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: "11.0" | |
| - name: Retag wheel with platform | |
| run: | | |
| uv tool install wheel | |
| uvx wheel tags --platform-tag=macosx_11_0_arm64 --remove dist/*.whl | |
| - name: Test wheel installation and compile | |
| run: | | |
| WHEEL=$(ls dist/*.whl) | |
| uv tool install "$WHEEL" | |
| export PATH="$HOME/.local/bin:$PATH" | |
| jst compile -m python/models/models_onnx/lenet.onnx -c ./test_circuit.txt | |
| if [[ ! -f ./test_circuit.txt ]]; then | |
| echo "Error: Circuit file was not created" | |
| exit 1 | |
| fi | |
| echo "Wheel test passed" | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: wheel-macos-aarch64 | |
| path: ./dist/*.whl | |
| publish: | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| needs: [build-linux, build-macos] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download all wheels | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: wheel-* | |
| merge-multiple: true | |
| path: ./dist | |
| - name: Extract version from tag | |
| id: get_version | |
| shell: bash | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release with wheels | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: Release ${{ steps.get_version.outputs.version }} | |
| files: ./dist/*.whl | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Publish to PyPI | |
| run: uv publish ./dist/* |