|
| 1 | +# This workflows will upload a Python Package using Twine when a release is created |
| 2 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 3 | + |
| 4 | +name: test and deploy |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + name: ${{ matrix.platform }} py${{ matrix.python-version }} |
| 20 | + runs-on: ${{ matrix.platform }} |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | +# platform: [ubuntu-latest, windows-latest] # , macos-latest |
| 24 | + platform: [ubuntu-latest] |
| 25 | + python-version: ['3.8', '3.9'] #issues with monai and 3.10; pausing for now. users should use python 3.9 |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + uses: actions/setup-python@v4 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + |
| 35 | +# these libraries enable testing on Qt on linux |
| 36 | + - uses: tlambert03/setup-qt-libs@v1 |
| 37 | + |
| 38 | +# strategy borrowed from vispy for installing opengl libs on windows |
| 39 | + - name: Install Windows OpenGL |
| 40 | + if: runner.os == 'Windows' |
| 41 | + run: | |
| 42 | + git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git |
| 43 | + powershell gl-ci-helpers/appveyor/install_opengl.ps1 |
| 44 | + if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1} |
| 45 | +
|
| 46 | +# note: if you need dependencies from conda, considering using |
| 47 | +# setup-miniconda: https://github.com/conda-incubator/setup-miniconda |
| 48 | +# and |
| 49 | +# tox-conda: https://github.com/tox-dev/tox-conda |
| 50 | + - name: Install dependencies |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + python -m pip install setuptools tox tox-gh-actions |
| 54 | + python -m pip install napari_cellseg3d |
| 55 | +
|
| 56 | +# this runs the platform-specific tests declared in tox.ini |
| 57 | + - name: Test with tox |
| 58 | + uses: GabrielBB/xvfb-action@v1 # aganders3/headless-gui@v1 |
| 59 | + with: |
| 60 | + run: python -m tox |
| 61 | + env: |
| 62 | + PLATFORM: ${{ matrix.platform }} |
| 63 | + |
| 64 | + - name: Coverage |
| 65 | + uses: codecov/codecov-action@v2 |
| 66 | + |
| 67 | + deploy: |
| 68 | +# this will run when you have tagged a commit, starting with "v*" |
| 69 | +# and requires that you have put your twine API key in your |
| 70 | +# github secrets (see readme for details) |
| 71 | + needs: [test] |
| 72 | + runs-on: ubuntu-latest |
| 73 | + if: contains(github.ref, 'tags') |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v2 |
| 76 | + - name: Set up Python |
| 77 | + uses: actions/setup-python@v2 |
| 78 | + with: |
| 79 | + python-version: "3.x" |
| 80 | + - name: Install dependencies |
| 81 | + run: | |
| 82 | + python -m pip install --upgrade pip |
| 83 | + pip install -U setuptools setuptools_scm wheel twine build |
| 84 | + - name: Build and publish |
| 85 | + env: |
| 86 | + TWINE_USERNAME: __token__ |
| 87 | + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} |
| 88 | + run: | |
| 89 | + git tag |
| 90 | + python -m build . |
| 91 | + twine upload dist/* |
0 commit comments