Skip to content

Commit

Permalink
Refactor publishing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed Jun 1, 2023
1 parent 06c6e81 commit b5c8f8a
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 124 deletions.
266 changes: 142 additions & 124 deletions .github/workflows/python-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,61 @@ on: [push]

jobs:
test_rust:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- run: |
cd rust
cargo test
- uses: actions/checkout@v3
- run: |
cd rust
cargo test
build_lin:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- name: Build testing docker container
run: |
docker build -f python/Dockerfile -t testing .
- name: Build
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "
\$PYBIN/python setup.py install
\$PYBIN/python setup.py bdist_wheel -p manylinux2014_x86_64"
- name: Test
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "\$PYBIN/pytest tests -v"
- name: Check formatting
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "\$PYBIN/black --check ."
- name: Try to import on different python versions
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "
for PYBIN in /opt/python/{cp37-cp37m,cp38-cp38,cp39-cp39,cp310-cp310,cp311-cp311}/bin; do
echo '-->' \$PYBIN
\$PYBIN/pip install /app/python/dist/wkw-*-py3-none-manylinux2014_x86_64.whl
\$PYBIN/python -c 'import wkw; print(wkw.Dataset)'
\$PYBIN/pytest tests -v
done"
- name: Publish
if: startsWith(github.event.ref, 'refs/tags')
run: |
docker run \
-v$(pwd):/app \
"-eTWINE_USERNAME=${{ secrets.PYPI_USERNAME }}" \
"-eTWINE_PASSWORD=${{ secrets.PYPI_PASSWORD }}" \
-w/app/python \
testing \
bash -c "\$PYBIN/python setup.py sdist bdist_wheel -p manylinux1_x86_64 && \$PYBIN/twine upload dist/*.whl dist/*.tar.gz"
- uses: actions/checkout@v3
- name: Build testing docker container
run: |
docker build -f python/Dockerfile -t testing .
- name: Build
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "
\$PYBIN/python setup.py install
\$PYBIN/python setup.py bdist_wheel -p manylinux2014_x86_64"
- name: Test
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "\$PYBIN/pytest tests -v"
- name: Check formatting
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "\$PYBIN/black --check ."
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./python/dist/*.whl

- name: Make sdist
run: |
docker run \
-v$(pwd):/app \
-w/app/python \
testing \
bash -c "\$PYBIN/python setup.py sdist"
- uses: actions/upload-artifact@v3
with:
name: targz
path: ./python/dist/*.tar.gz

build_mac:
runs-on: macos-12
Expand All @@ -72,42 +67,36 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64' # (x64 or x86)
- name: Install Rust
run: |
brew install rustup-init
rustup-init -y
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Build
run: |
cd python
export PATH=$PATH:$HOME/.cargo/bin
pip install twine wheel
python setup.py bdist_wheel -p macosx-10.9-universal2
pip install dist/*.whl
- name: Test
run: |
cd python
python -c "import wkw"
pip install pytest
pytest tests
- name: Publish
if: startsWith(github.event.ref, 'refs/tags') && matrix.python-version == '3.8'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
cd python
rm -rf dist
export PATH=$PATH:$HOME/.cargo/bin
python setup.py sdist bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform().replace('x86_64', 'universal2'))")
twine upload dist/*.whl
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: "x64" # (x64 or x86)
- name: Install Rust
run: |
brew install rustup-init
rustup-init -y
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Build
run: |
cd python
export PATH=$PATH:$HOME/.cargo/bin
pip install wheel
python setup.py bdist_wheel -p macosx-10.9-universal2
pip install dist/*.whl
- name: Test
run: |
cd python
python -c "import wkw"
pip install pytest
pytest tests
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./python/dist/*.whl

build_win:
runs-on: windows-2022
Expand All @@ -119,36 +108,65 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64' # (x64 or x86)
- name: Build
run: |
cd python
pip install twine wheel
python setup.py bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
pip install dist/*.whl
- name: Test
run: |
cd python
python -c "import wkw"
pip install pytest
pytest tests -k "not big_read"
- name: Test (non-bash)
run: |
cd python
python -c "import wkw"
pytest tests -k "not big_read"
- name: Publish
if: startsWith(github.event.ref, 'refs/tags') && matrix.python-version == '3.8'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
cd python
rm -rf dist
python setup.py sdist bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
twine upload dist/*.whl
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: "x64" # (x64 or x86)
- name: Build
run: |
cd python
pip install wheel
python setup.py bdist_wheel -p $(python -c "import distutils.util; print(distutils.util.get_platform())")
pip install dist/*.whl
- name: Test
run: |
cd python
python -c "import wkw"
pip install pytest
pytest tests -k "not big_read"
- name: Test (non-bash)
shell: cmd
run: |
cd python
python -c "import wkw"
pytest tests -k "not big_read"
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./python/dist/*.whl

publish:
needs:
- test_rust
- build_lin
- build_mac
- build_win
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Get wheels
uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Get tar.gz
uses: actions/download-artifact@v3
with:
name: targz
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
skip-existing: true
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def run(self):
author="Alessandro Motta",
author_email="alessandro.motta@brain.mpg.de",
url="https://github.com/scalableminds/webknossos-wrap",
long_description_content_type="text/markdown",
packages=find_packages(),
include_package_data=True,
license="MIT",
Expand Down

0 comments on commit b5c8f8a

Please sign in to comment.