|
1 | | -name: Upload Python Package |
| 1 | +name: Build and upload to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | release: |
6 | | - types: [created] |
| 6 | + types: [published] |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - deploy-linux: |
10 | | - runs-on: ubuntu-18.04 |
11 | | - steps: |
12 | | - - uses: actions/checkout@v2 |
13 | | - - name: Set up Python |
14 | | - uses: actions/setup-python@v1 |
15 | | - with: |
16 | | - python-version: '3.x' |
17 | | - - name: Update submodules |
18 | | - run: | |
19 | | - git submodule update --init |
20 | | - - name: Build manylinux Python wheels |
21 | | - uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2010_x86_64 |
22 | | - with: |
23 | | - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' |
24 | | - build-requirements: 'cython' |
25 | | - system-packages: 'patchelf' |
26 | | - - name: Publish wheels to PyPI |
27 | | - if: github.event_name == 'release' |
28 | | - env: |
29 | | - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
30 | | - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
31 | | - run: | |
32 | | - python -m pip install twine |
33 | | - twine upload --skip-existing dist/*-manylinux*.whl |
34 | | -
|
35 | | - deploy-macos: |
36 | | - runs-on: macos-10.15 |
| 9 | + build_wheels: |
| 10 | + name: Build wheels on ${{ matrix.os }} |
| 11 | + runs-on: ${{ matrix.os }} |
37 | 12 | strategy: |
38 | 13 | matrix: |
39 | | - python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"] |
| 14 | + os: [ubuntu-20.04, windows-2019, macos-11] |
40 | 15 | steps: |
41 | | - - uses: actions/checkout@v2 |
42 | | - - name: Set up Python ${{ matrix.python-version }} |
43 | | - uses: actions/setup-python@v1 |
44 | | - with: |
45 | | - python-version: ${{ matrix.python-version }} |
46 | | - - name: Install dependencies |
47 | | - run: | |
48 | | - curl -L https://github.com/casey/just/releases/download/v0.5.8/just-v0.5.8-x86_64-apple-darwin.tar.gz | tar -vzx just |
49 | | - sudo mv just /usr/local/bin |
50 | | - just script/unix/ci-bootstrap |
51 | | - - name: Build wheels |
52 | | - run: | |
53 | | - just script/unix/ci-dist |
54 | | - - name: Publish wheels to PyPI |
55 | | - if: github.event_name == 'release' |
56 | | - env: |
57 | | - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
58 | | - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
59 | | - run: | |
60 | | - python -m pip install twine |
61 | | - twine upload --skip-existing dist/*.whl dist/*.tar.gz |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + submodules: true |
62 | 19 |
|
63 | | - deploy-windows: |
64 | | - runs-on: windows-2019 |
65 | | - strategy: |
66 | | - matrix: |
67 | | - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] |
| 20 | + - name: Build wheels |
| 21 | + uses: pypa/cibuildwheel@v2.11.2 |
| 22 | + env: |
| 23 | + CIBW_BUILD_VERBOSITY: 1 |
| 24 | + CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-* cp311-*" |
| 25 | + CIBW_SKIP: "pp* *-musllinux* *_aarch64 *_ppc64le *_s390x *_i686 *_universal2" |
| 26 | + |
| 27 | + - uses: actions/upload-artifact@v3 |
| 28 | + with: |
| 29 | + path: ./wheelhouse/*.whl |
| 30 | + |
| 31 | + build_sdist: |
| 32 | + name: Build source distribution |
| 33 | + runs-on: ubuntu-latest |
68 | 34 | steps: |
69 | | - - uses: actions/checkout@v2 |
70 | | - - name: Set up Python ${{ matrix.python-version }} |
71 | | - uses: actions/setup-python@v1 |
72 | | - with: |
73 | | - python-version: ${{ matrix.python-version }} |
74 | | - - name: Install dependencies |
75 | | - run: | |
76 | | - $JustVersion = "v0.5.8" |
77 | | - Invoke-WebRequest -Uri https://github.com/casey/just/releases/download/$JustVersion/just-$JustVersion-x86_64-pc-windows-msvc.zip -OutFile just-$JustVersion-x86_64-pc-windows-msvc.zip |
78 | | - Expand-Archive .\just-$JustVersion-x86_64-pc-windows-msvc.zip unzipped |
79 | | - $Env:Path = (Join-Path (Get-Location) "unzipped") + ";" + $Env:Path |
80 | | - just script/windows/ci-bootstrap |
81 | | - - name: Build wheels |
82 | | - run: | |
83 | | - $Env:Path = (Join-Path (Get-Location) "unzipped") + ";" + $Env:Path |
84 | | - just script/windows/ci-dist |
85 | | - - name: Publish wheels to PyPI |
86 | | - if: github.event_name == 'release' |
87 | | - env: |
88 | | - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
89 | | - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
90 | | - run: | |
91 | | - python -m pip install twine |
92 | | - twine upload --skip-existing dist/*.whl |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + submodules: true |
| 38 | + |
| 39 | + - name: Build sdist |
| 40 | + run: pipx run build --sdist |
| 41 | + |
| 42 | + - uses: actions/upload-artifact@v3 |
| 43 | + with: |
| 44 | + path: dist/*.tar.gz |
| 45 | + |
| 46 | + upload_pypi: |
| 47 | + needs: [build_wheels, build_sdist] |
| 48 | + runs-on: ubuntu-latest |
| 49 | + # upload to PyPI on every tag starting with 'v' |
| 50 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 51 | + # alternatively, to publish when a GitHub Release is created, use the following rule: |
| 52 | + # if: github.event_name == 'release' && github.event.action == 'published' |
| 53 | + steps: |
| 54 | + - uses: actions/download-artifact@v3 |
| 55 | + with: |
| 56 | + # unpacks default artifact into dist/ |
| 57 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 58 | + name: artifact |
| 59 | + path: dist |
| 60 | + |
| 61 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 62 | + with: |
| 63 | + skip_existing: true |
| 64 | + user: ${{ secrets.PYPI_USERNAME }} |
| 65 | + password: ${{ secrets.PYPI_PASSWORD }} |
| 66 | + # To test: repository_url: https://test.pypi.org/legacy/ |
0 commit comments