Skip to content

Commit 4d1c493

Browse files
authored
Merge pull request #144 from Gerrit-K/travis-to-github
Add GitHub workflow for building and publishing
2 parents 0d71d2d + 19fe2d0 commit 4d1c493

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
build_wheels:
12+
name: "Build wheels on ${{ matrix.os }}"
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
steps:
19+
- uses: "actions/checkout@v3"
20+
with:
21+
submodules: true
22+
- name: "Build wheels"
23+
uses: "pypa/cibuildwheel@v2.3.1"
24+
env:
25+
CIBW_SKIP: "pp*" # FIXME
26+
CIBW_BEFORE_BUILD: "pip install -U cython && ./update_cpp.sh"
27+
CIBW_BEFORE_BUILD_WINDOWS: "pip install -U cython && update_cpp.sh"
28+
CIBW_TEST_REQUIRES: "pytest"
29+
CIBW_TEST_COMMAND: "pytest {project}/tests --doctest-modules"
30+
- uses: "actions/upload-artifact@v3"
31+
with:
32+
path: "./wheelhouse/*.whl"
33+
34+
make_sdist:
35+
name: "Build source distribution"
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: "actions/checkout@v2"
39+
with:
40+
submodules: true
41+
- name: "Install dependencies"
42+
run: "python -m pip install --upgrade cython"
43+
- name: "Rebuild CPP files using Cython"
44+
run: "./update_cpp.sh"
45+
- name: "Build source distribution"
46+
run: "pipx run build --sdist"
47+
- uses: "actions/upload-artifact@v3"
48+
with:
49+
path: "./dist/*.tar.gz"
50+
51+
upload_to_pypi:
52+
name: "Upload to PyPI"
53+
runs-on: ubuntu-latest
54+
needs:
55+
- build_wheels
56+
- make_sdist
57+
if: github.event_name == 'release' && github.event.action == 'published'
58+
steps:
59+
- uses: "actions/download-artifact@v3"
60+
with:
61+
name: artifact
62+
path: dist
63+
- uses: "pypa/gh-action-pypi-publish@v1.5.0"
64+
with:
65+
user: __token__
66+
password: ${{ secrets.PYPI_TOKEN }}
67+
print_hash: true
68+
verbose: true

0 commit comments

Comments
 (0)