From c939c37a0565bb8018c8a01e5f642f3259f99cdf Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 11 Mar 2024 19:00:35 -0700 Subject: [PATCH] .github/workflows/build_wheels.yml: Update to pypa/cibuildwheel@v2.17.0, upload to PyPI on tags --- .github/workflows/build_wheels.yml | 79 +++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index b233fca..6abff9a 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -1,4 +1,4 @@ -name: Build wheels and tar +name: Build wheels and sdist on: pull_request: @@ -6,40 +6,75 @@ on: push: tags: - '*' + workflow_dispatch: jobs: + + sdists_for_pypi: + name: Build sdist (and upload to PyPI on release tags) + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - name: make sdist + run: | + pipx run build -s + - uses: actions/upload-artifact@v3 + with: + path: "dist/*.tar.gz" + name: dist + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + build_wheels: - name: Wheels on ${{ matrix.os }} + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macOS-latest, macOS-14] + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v4 - name: Build wheels - uses: pypa/cibuildwheel@v2.6.0 - # to supply options, put them in 'env', like: - # env: - # CIBW_SOME_OPTION: value + uses: pypa/cibuildwheel@v2.17.0 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: + name: wheels path: ./wheelhouse/*.whl - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' + pypi-publish: + # https://github.com/pypa/gh-action-pypi-publish + name: Upload wheels to PyPI + needs: build_wheels + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: - - name: Build sdist - run: python setup.py sdist + - uses: actions/download-artifact@v3 + with: + name: wheels + path: wheelhouse - - uses: actions/upload-artifact@v2 + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - path: dist/*.tar.gz + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + packages_dir: wheelhouse/ + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true'