Added description #12
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 Python Wheels | |
| on: | |
| push: | |
| paths: | |
| - 'Cargo.toml' | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| version: | |
| name: Extract version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Extract version from Cargo.toml | |
| id: get_version | |
| run: | | |
| VERSION=$(grep -m 1 "version" Cargo.toml | cut -d '"' -f 2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Package version: $VERSION" | |
| build: | |
| name: Build wheels on ${{ matrix.os }} | |
| needs: version | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-latest, macos-latest, ubuntu-latest] | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
| include: | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install Maturin | |
| run: pip install maturin | |
| - name: Build wheels | |
| run: | | |
| if (!(Test-Path -Path "wheels")) { New-Item -ItemType Directory -Path "wheels" } | |
| maturin build --release --target ${{ matrix.target }} --out wheels | |
| shell: pwsh | |
| - name: List build directory | |
| run: Get-ChildItem -Recurse wheels | |
| shell: pwsh | |
| - name: Upload wheels as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ matrix.python-version }} | |
| path: wheels/*.whl | |
| publish: | |
| name: Publish to PyPI | |
| needs: [version, build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Display structure of downloaded files | |
| run: find dist -type f | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| skip_existing: true | |
| # Uncomment to test on TestPyPI first | |
| # repository_url: https://test.pypi.org/legacy/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/*.whl | |
| generate_release_notes: true | |
| tag_name: v${{ needs.version.outputs.version }} | |
| token: ${{ secrets.RELEASE_TOKEN }} |