Skip to content

Commit d712793

Browse files
ci: add deploy workflow (#1594)
This patch adds a deploy workflow for automatically deploying the package to PYPI when a release is "published". According to the docs for "published": > published: a release, pre-release, or draft of a release is published [source](https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#release) Unfortunately Github actions [doesn't have a manual approval step](https://github.community/t/github-actions-manual-trigger-approvals/16233/85) which would be ideal to use here. This is based off of the [cibuildwheel example](https://github.com/joerick/cibuildwheel/blob/5c4767899dc4418b509a2d7ccfde07d33ab29e28/examples/github-deploy.yml) and our modifications made in #1554. Co-authored-by: Brett Langdon <[email protected]>
1 parent 9195ac4 commit d712793

File tree

2 files changed

+79
-40
lines changed

2 files changed

+79
-40
lines changed

.github/workflows/build_deploy.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-18.04, windows-latest, macos-latest]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
# Include all history and tags
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: actions/setup-python@v2
24+
name: Install Python
25+
with:
26+
python-version: '3.8'
27+
28+
- name: Install cibuildwheel
29+
run: |
30+
python -m pip install cibuildwheel==1.5.5
31+
32+
- name: Build wheels
33+
run: |
34+
python -m cibuildwheel --output-dir wheelhouse
35+
env:
36+
CIBW_SKIP: pp* cp27-win*
37+
38+
- uses: actions/upload-artifact@v2
39+
with:
40+
path: ./wheelhouse/*.whl
41+
42+
build_sdist:
43+
name: Build source distribution
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v2
47+
# Include all history and tags
48+
with:
49+
fetch-depth: 0
50+
51+
- uses: actions/setup-python@v2
52+
name: Install Python
53+
with:
54+
python-version: '3.7'
55+
56+
- name: Build sdist
57+
run: |
58+
pip install cython
59+
python setup.py sdist
60+
61+
- uses: actions/upload-artifact@v2
62+
with:
63+
path: dist/*.tar.gz
64+
65+
upload_pypi:
66+
needs: [build_wheels, build_sdist]
67+
runs-on: ubuntu-latest
68+
if: github.event_name == 'release' && github.event.action == 'published'
69+
steps:
70+
- uses: actions/download-artifact@v2
71+
with:
72+
name: artifact
73+
path: dist
74+
75+
- uses: pypa/gh-action-pypi-publish@master
76+
with:
77+
user: __token__
78+
password: ${{ secrets.PYPI_TOKEN }}
79+
# To test: repository_url: https://test.pypi.org/legacy/

.github/workflows/wheels.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)