diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml deleted file mode 100644 index 00c7845..0000000 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: PyPi Build and Deploy 🐍📦 - -on: - release: - types: [published] - # use this for testing - push: - branches: - - main - -jobs: - build-n-publish: - name: Build and publish ppfive on PyPi - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/project/ppfive/ - permissions: - # IMPORTANT: this permission is mandatory for trusted publishing - id-token: write - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - name: Set up Python 3.14 - uses: actions/setup-python@v6 - with: - python-version: "3.14" - - name: Install pep517 - run: >- - python -m - pip install - pep517 - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - pep517.build - --source - --binary - --out-dir dist/ - . - ### test for Test PyPI - # - name: Publish distribution to Test PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # repository-url: https://test.pypi.org/legacy/ - ### - - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/build-and-deploy-wheels-on-pypi.yml b/.github/workflows/build-and-deploy-wheels-on-pypi.yml new file mode 100644 index 0000000..ffd1c66 --- /dev/null +++ b/.github/workflows/build-and-deploy-wheels-on-pypi.yml @@ -0,0 +1,101 @@ +name: Build and Publish Wheels + +on: + release: + types: [published] + # use this for testing + push: + branches: + - main + +permissions: + contents: read + id-token: write # required for PyPI trusted publishing + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] # macos-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build wheels + uses: pypa/cibuildwheel@v3.2.1 + env: + # Build CPython 3.11-3.14 + CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*" + CIBW_SKIP: "*-musllinux_* pp*" + # Run tests after build (optional) + # CIBW_TEST_COMMAND: "python -c \"import ppfive; print('import ok')\"" + + - name: Upload wheel artifacts + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install build backend + run: python -m pip install --upgrade build + + - name: Build sdist + run: python -m build --sdist + + - name: Upload sdist artifact + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + + publish: + name: Publish to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + # publish only on version tags like v0.1.0 + if: startsWith(github.ref, 'refs/tags') + environment: + name: pypi + url: https://pypi.org/project/ppfive/ + permissions: + id-token: write + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: distfiles + + - name: Flatten artifacts + run: | + mkdir upload + find distfiles -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec cp {} upload/ \; + ls -la upload + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: upload