Merge pull request #7 from craftsangjae/fix/drop-windows #7
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: Publish to PyPI | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if version tag already exists | |
| id: check | |
| run: | | |
| VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| echo "Tag v$VERSION already exists, skipping release" | |
| echo "should_release=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Tag v$VERSION does not exist, proceeding with release" | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| test: | |
| needs: check-version | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ".[dev]" | |
| - name: Run tests | |
| run: pytest -v | |
| build-wheels: | |
| needs: [check-version, test] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64 | |
| - os: ubuntu-latest | |
| target: aarch64 | |
| - os: macos-latest | |
| target: x86_64 | |
| - os: macos-latest | |
| target: aarch64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| args: --release --out dist --interpreter 3.9 3.10 3.11 3.12 3.13 | |
| manylinux: auto | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ matrix.target }} | |
| path: dist | |
| build-sdist: | |
| needs: [check-version, test] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-sdist | |
| path: dist | |
| publish: | |
| needs: [check-version, build-wheels, build-sdist] | |
| if: always() && needs.check-version.outputs.should_release == 'true' && (needs.build-wheels.result == 'success' || needs.build-sdist.result == 'success') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create version tag | |
| run: | | |
| VERSION=${{ needs.check-version.outputs.version }} | |
| git tag "v$VERSION" | |
| git push origin "v$VERSION" | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| merge-multiple: true | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: dist/* | |
| generate_release_notes: true | |
| body: | | |
| ## Installation | |
| ```bash | |
| pip install muvera-python==${{ needs.check-version.outputs.version }} | |
| ``` | |
| See [PyPI](https://pypi.org/project/muvera-python/${{ needs.check-version.outputs.version }}/) for full package details. |