From 64b9c298a5469ab8f4e863645d1f469b5e2dc758 Mon Sep 17 00:00:00 2001 From: jvsguerra Date: Mon, 4 Nov 2024 11:55:14 -0300 Subject: [PATCH] Update deploy workflow --- .github/workflows/deploy.yml | 82 +++++++++++++++++++++++++++ .github/workflows/publish-release.yml | 66 --------------------- 2 files changed, 82 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..acb405c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,82 @@ +name: Build and deploy + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Build sdist + run: | + pipx run build --sdist + + - name: Test sdist + run: | + pip install dist/*.tar.gz + + - uses: actions/upload-artifact@v3 + with: + name: artifacts + path: dist/*.tar.gz + + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [macos-latest, macos-13, ubuntu-latest, windows-latest] + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.19.2 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v3 + with: + name: artifacts + path: ./wheelhouse/*.whl + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + needs: [build_sdist, build_wheels] + environment: + name: pypi + url: https://pypi.org/p/SERD/ + permissions: + id-token: write + + steps: + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - uses: actions/download-artifact@v3 + with: + name: artifacts + path: ./dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index c86a4a6..0000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Python package build and publish - -on: - release: - types: [ created ] - -jobs: - - deploy-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - 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 twine flake8 - - name: Lint with flake8 for syntax errors - run: | - pip install flake8 - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Build manylinux Python wheels - uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64 - with: - python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310' - build-requirements: 'cython numpy' - - name: Publish wheels to PyPI - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - pip install -U twine - twine upload dist/*-manylinux*.whl - continue-on-error: true - - deploy-macos: - runs-on: macos-10.15 - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - CC: /usr/local/bin/gcc-10 - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10'] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - brew install swig gcc@10 - - name: build wheel - run: | - pip install wheel - python setup.py bdist_wheel - - name: upload wheel - run: | - pip install twine - twine upload dist/* - continue-on-error: true \ No newline at end of file