From a1dfeae49a1b0c09d27352afe9fb677ec89d927c Mon Sep 17 00:00:00 2001 From: doronz88 Date: Sun, 3 Mar 2024 22:08:50 +0200 Subject: [PATCH] ci: refactor using `cibuildwheel` --- .github/workflows/build.yml | 30 ------------ .../python-publish-macos-and-linux.yml | 48 +++++++++++++++++++ .github/workflows/python-publish.yml | 38 --------------- 3 files changed, 48 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/python-publish-macos-and-linux.yml delete mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 7fee091..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build - -on: [push, pull_request, workflow_dispatch] - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ ubuntu-latest, macos-latest ] - - steps: - - uses: actions/checkout@v3 - - name: Build wheels - uses: pypa/cibuildwheel@v2.10.2 - env: - CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* - CIBW_ARCHS: auto64 - - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz diff --git a/.github/workflows/python-publish-macos-and-linux.yml b/.github/workflows/python-publish-macos-and-linux.yml new file mode 100644 index 0000000..eb44378 --- /dev/null +++ b/.github/workflows/python-publish-macos-and-linux.yml @@ -0,0 +1,48 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload python package for macOS & linux + +on: + release: + types: [ created ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + if: '! github.event.pull_request.draft' + runs-on: ${{ matrix.os }} + + strategy: + matrix: + include: + - os: macos-latest + arch: arm64 + - os: macos-latest + arch: x86_64 + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest + arch: i686 + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U build setuptools wheel twine cibuildwheel + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + CIBW_ARCHS: ${{ matrix.arch }} + run: | + cibuildwheel --output-dir dist + twine upload dist/* --skip-existing \ No newline at end of file diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 08af5a3..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package - - -on: - release: - types: [created] - - -jobs: - deploy: - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - python-version: [ 3.8, 3.9, "3.10", "3.11" ] - os: [ ubuntu-latest, macos-latest ] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -U build setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python -m build - twine upload dist/* \ No newline at end of file