|
| 1 | +name: Python package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + pull_request: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + python-version: [3.7, 3.8, 3.9, "3.10"] |
| 17 | + fail-fast: false |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v2 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 29 | + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi |
| 30 | + - name: Install |
| 31 | + run: | |
| 32 | + make install |
| 33 | + - name: Lint with flake8 |
| 34 | + run: | |
| 35 | + # stop the build if there are Python syntax errors or undefined names |
| 36 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 37 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 38 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 39 | + - name: Run unit tests |
| 40 | + run: | |
| 41 | + make test |
| 42 | +
|
| 43 | + deploy: |
| 44 | + name: "Deploy to PyPI" |
| 45 | + runs-on: ubuntu-latest |
| 46 | + if: github.event_name == 'release' |
| 47 | + needs: [build] |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v2 |
| 50 | + - name: "Set up Python 3.8" |
| 51 | + uses: actions/setup-python@v2 |
| 52 | + with: |
| 53 | + python-version: "3.8" |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + python -m pip install --upgrade pip |
| 57 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 58 | + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi |
| 59 | + - name: "Build Package" |
| 60 | + run: | |
| 61 | + make dist |
| 62 | +
|
| 63 | + # test deploy ---- |
| 64 | + - name: "Test Deploy to PyPI" |
| 65 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 66 | + if: startsWith(github.event.release.name, 'TEST') |
| 67 | + with: |
| 68 | + user: __token__ |
| 69 | + password: ${{ secrets.PYPI_TEST_API_TOKEN }} |
| 70 | + repository_url: https://test.pypi.org/legacy/ |
| 71 | + |
| 72 | + ## prod deploy ---- |
| 73 | + - name: "Deploy to PyPI" |
| 74 | + uses: pypa/gh-action-pypi-publish@master |
| 75 | + if: startsWith(github.event.release.name, 'shinywidgets') |
| 76 | + with: |
| 77 | + user: __token__ |
| 78 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments