Skip to content

Commit

Permalink
update python-publish GHA to build multi-platform wheels (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongyoonlee committed Apr 19, 2024
1 parent f6f75db commit b16d3b5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
73 changes: 52 additions & 21 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This workflow 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
# Updated with cibuildwheel: https://learn.scientific-python.org/development/guides/gha-wheels/

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
Expand All @@ -9,32 +10,62 @@
name: Upload Python Package

on:
workflow_dispatch:
release:
types: [published]
types:
- published

jobs:
deploy:

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: false # Optional, use if you have submodules

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

build_wheels:
name: Wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8']
os: [ubuntu-latest, windows-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install .
python -m build
python -m twine upload dist/*.tar.gz
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- uses: pypa/cibuildwheel@v2.17

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
path: wheelhouse/*.whl

upload_all:
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env_docs/
__pycache__
build
dist
wheelhouse
*.pyc
_build/
.ipynb_checkpoints/
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ requires = [

[project.urls]
homepage = "https://github.com/uber/causalml"

[tool.cibuildwheel]
build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*"]
build-verbosity = 1

0 comments on commit b16d3b5

Please sign in to comment.