Skip to content

Commit b5c8f8a

Browse files
committed
Refactor publishing in CI
1 parent 06c6e81 commit b5c8f8a

File tree

2 files changed

+143
-124
lines changed

2 files changed

+143
-124
lines changed

.github/workflows/python-module.yml

Lines changed: 142 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,61 @@ on: [push]
44

55
jobs:
66
test_rust:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
88
steps:
9-
- uses: actions/checkout@v1
10-
- run: |
11-
cd rust
12-
cargo test
9+
- uses: actions/checkout@v3
10+
- run: |
11+
cd rust
12+
cargo test
1313
1414
build_lin:
1515
runs-on: ubuntu-22.04
1616
steps:
17-
- uses: actions/checkout@v1
18-
- name: Build testing docker container
19-
run: |
20-
docker build -f python/Dockerfile -t testing .
21-
- name: Build
22-
run: |
23-
docker run \
24-
-v$(pwd):/app \
25-
-w/app/python \
26-
testing \
27-
bash -c "
28-
\$PYBIN/python setup.py install
29-
\$PYBIN/python setup.py bdist_wheel -p manylinux2014_x86_64"
30-
- name: Test
31-
run: |
32-
docker run \
33-
-v$(pwd):/app \
34-
-w/app/python \
35-
testing \
36-
bash -c "\$PYBIN/pytest tests -v"
37-
- name: Check formatting
38-
run: |
39-
docker run \
40-
-v$(pwd):/app \
41-
-w/app/python \
42-
testing \
43-
bash -c "\$PYBIN/black --check ."
44-
- name: Try to import on different python versions
45-
run: |
46-
docker run \
47-
-v$(pwd):/app \
48-
-w/app/python \
49-
testing \
50-
bash -c "
51-
for PYBIN in /opt/python/{cp37-cp37m,cp38-cp38,cp39-cp39,cp310-cp310,cp311-cp311}/bin; do
52-
echo '-->' \$PYBIN
53-
\$PYBIN/pip install /app/python/dist/wkw-*-py3-none-manylinux2014_x86_64.whl
54-
\$PYBIN/python -c 'import wkw; print(wkw.Dataset)'
55-
\$PYBIN/pytest tests -v
56-
done"
57-
- name: Publish
58-
if: startsWith(github.event.ref, 'refs/tags')
59-
run: |
60-
docker run \
61-
-v$(pwd):/app \
62-
"-eTWINE_USERNAME=${{ secrets.PYPI_USERNAME }}" \
63-
"-eTWINE_PASSWORD=${{ secrets.PYPI_PASSWORD }}" \
64-
-w/app/python \
65-
testing \
66-
bash -c "\$PYBIN/python setup.py sdist bdist_wheel -p manylinux1_x86_64 && \$PYBIN/twine upload dist/*.whl dist/*.tar.gz"
17+
- uses: actions/checkout@v3
18+
- name: Build testing docker container
19+
run: |
20+
docker build -f python/Dockerfile -t testing .
21+
- name: Build
22+
run: |
23+
docker run \
24+
-v$(pwd):/app \
25+
-w/app/python \
26+
testing \
27+
bash -c "
28+
\$PYBIN/python setup.py install
29+
\$PYBIN/python setup.py bdist_wheel -p manylinux2014_x86_64"
30+
- name: Test
31+
run: |
32+
docker run \
33+
-v$(pwd):/app \
34+
-w/app/python \
35+
testing \
36+
bash -c "\$PYBIN/pytest tests -v"
37+
- name: Check formatting
38+
run: |
39+
docker run \
40+
-v$(pwd):/app \
41+
-w/app/python \
42+
testing \
43+
bash -c "\$PYBIN/black --check ."
44+
45+
- uses: actions/upload-artifact@v3
46+
with:
47+
name: wheels
48+
path: ./python/dist/*.whl
49+
50+
- name: Make sdist
51+
run: |
52+
docker run \
53+
-v$(pwd):/app \
54+
-w/app/python \
55+
testing \
56+
bash -c "\$PYBIN/python setup.py sdist"
57+
58+
- uses: actions/upload-artifact@v3
59+
with:
60+
name: targz
61+
path: ./python/dist/*.tar.gz
6762

6863
build_mac:
6964
runs-on: macos-12
@@ -72,42 +67,36 @@ jobs:
7267
matrix:
7368
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
7469
steps:
75-
- uses: actions/checkout@v1
76-
- name: Set up Python ${{ matrix.python-version }}
77-
uses: actions/setup-python@v1
78-
with:
79-
python-version: ${{ matrix.python-version }}
80-
architecture: 'x64' # (x64 or x86)
81-
- name: Install Rust
82-
run: |
83-
brew install rustup-init
84-
rustup-init -y
85-
rustup target add aarch64-apple-darwin
86-
rustup target add x86_64-apple-darwin
87-
- name: Build
88-
run: |
89-
cd python
90-
export PATH=$PATH:$HOME/.cargo/bin
91-
pip install twine wheel
92-
python setup.py bdist_wheel -p macosx-10.9-universal2
93-
pip install dist/*.whl
94-
- name: Test
95-
run: |
96-
cd python
97-
python -c "import wkw"
98-
pip install pytest
99-
pytest tests
100-
- name: Publish
101-
if: startsWith(github.event.ref, 'refs/tags') && matrix.python-version == '3.8'
102-
env:
103-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
104-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
105-
run: |
106-
cd python
107-
rm -rf dist
108-
export PATH=$PATH:$HOME/.cargo/bin
109-
python setup.py sdist bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform().replace('x86_64', 'universal2'))")
110-
twine upload dist/*.whl
70+
- uses: actions/checkout@v3
71+
- name: Set up Python ${{ matrix.python-version }}
72+
uses: actions/setup-python@v4
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
architecture: "x64" # (x64 or x86)
76+
- name: Install Rust
77+
run: |
78+
brew install rustup-init
79+
rustup-init -y
80+
rustup target add aarch64-apple-darwin
81+
rustup target add x86_64-apple-darwin
82+
- name: Build
83+
run: |
84+
cd python
85+
export PATH=$PATH:$HOME/.cargo/bin
86+
pip install wheel
87+
python setup.py bdist_wheel -p macosx-10.9-universal2
88+
pip install dist/*.whl
89+
- name: Test
90+
run: |
91+
cd python
92+
python -c "import wkw"
93+
pip install pytest
94+
pytest tests
95+
96+
- uses: actions/upload-artifact@v3
97+
with:
98+
name: wheels
99+
path: ./python/dist/*.whl
111100

112101
build_win:
113102
runs-on: windows-2022
@@ -119,36 +108,65 @@ jobs:
119108
matrix:
120109
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
121110
steps:
122-
- uses: actions/checkout@v1
123-
- name: Set up Python ${{ matrix.python-version }}
124-
uses: actions/setup-python@v1
125-
with:
126-
python-version: ${{ matrix.python-version }}
127-
architecture: 'x64' # (x64 or x86)
128-
- name: Build
129-
run: |
130-
cd python
131-
pip install twine wheel
132-
python setup.py bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
133-
pip install dist/*.whl
134-
- name: Test
135-
run: |
136-
cd python
137-
python -c "import wkw"
138-
pip install pytest
139-
pytest tests -k "not big_read"
140-
- name: Test (non-bash)
141-
run: |
142-
cd python
143-
python -c "import wkw"
144-
pytest tests -k "not big_read"
145-
- name: Publish
146-
if: startsWith(github.event.ref, 'refs/tags') && matrix.python-version == '3.8'
147-
env:
148-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
149-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
150-
run: |
151-
cd python
152-
rm -rf dist
153-
python setup.py sdist bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
154-
twine upload dist/*.whl
111+
- uses: actions/checkout@v3
112+
- name: Set up Python ${{ matrix.python-version }}
113+
uses: actions/setup-python@v4
114+
with:
115+
python-version: ${{ matrix.python-version }}
116+
architecture: "x64" # (x64 or x86)
117+
- name: Build
118+
run: |
119+
cd python
120+
pip install wheel
121+
python setup.py bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
122+
pip install dist/*.whl
123+
- name: Test
124+
run: |
125+
cd python
126+
python -c "import wkw"
127+
pip install pytest
128+
pytest tests -k "not big_read"
129+
- name: Test (non-bash)
130+
shell: cmd
131+
run: |
132+
cd python
133+
python -c "import wkw"
134+
pytest tests -k "not big_read"
135+
136+
- uses: actions/upload-artifact@v3
137+
with:
138+
name: wheels
139+
path: ./python/dist/*.whl
140+
141+
publish:
142+
needs:
143+
- test_rust
144+
- build_lin
145+
- build_mac
146+
- build_win
147+
runs-on: ubuntu-latest
148+
steps:
149+
- uses: actions/checkout@v3
150+
with:
151+
fetch-depth: "0"
152+
- name: Set up Python ${{ matrix.python-version }}
153+
uses: actions/setup-python@v4
154+
with:
155+
python-version: "3.10"
156+
- name: Get wheels
157+
uses: actions/download-artifact@v3
158+
with:
159+
name: wheels
160+
path: dist
161+
- name: Get tar.gz
162+
uses: actions/download-artifact@v3
163+
with:
164+
name: targz
165+
path: dist
166+
167+
- name: Publish to PyPI
168+
uses: pypa/gh-action-pypi-publish@release/v1
169+
with:
170+
user: __token__
171+
password: ${{ secrets.PYPI_PASSWORD }}
172+
skip-existing: true

python/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def run(self):
8484
author="Alessandro Motta",
8585
author_email="[email protected]",
8686
url="https://github.com/scalableminds/webknossos-wrap",
87+
long_description_content_type="text/markdown",
8788
packages=find_packages(),
8889
include_package_data=True,
8990
license="MIT",

0 commit comments

Comments
 (0)