diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d3fbff0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: Build Wheel and Release + +on: + push: + tags: + - v* + +permissions: + contents: read + +jobs: + build_wheels: + name: wheel for ${{ matrix.os }} + if: github.repository_owner == 'numpy' && startsWith(github.ref, 'refs/tags/v') + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: pypa/cibuildwheel@v3.2 + + - uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl + + build_sdist: + name: sdist + if: github.repository_owner == 'numpy' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: actions/setup-python@v7 + with: + python-version: "3.13" + + - name: Install spin + run: pip install spin + + - name: Build sdist + run: spin sdist + + - uses: actions/upload-artifact@v4 + with: + name: sdist + path: ./dist/*.tar.gz + + pypi-publish: + name: upload release to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + attestations: write + contents: read + steps: + - uses: actions/download-artifact@v4 + with: + pattern: wheels-* + path: dist + merge-multiple: true + - uses: actions/download-artifact@v4 + with: + name: sdist + path: dist + + - name: Generate artifact attestation for sdist and wheels + uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-path: "dist/numpy_financial-*" + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 diff --git a/pyproject.toml b/pyproject.toml index d854b4a..aea7a12 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,6 +112,11 @@ package = 'numpy_financial' ] +[tool.cibuildwheel] +build = "cp313-* cp314-*" +skip = "*-musllinux* *_i686 *-win32" +test-command = "python -c \"import numpy_financial\"" + [tool.ruff.lint] ignore = ["F403"] select = ["E", "F", "B", "I"]