|
1 |
| -name: Python package |
| 1 | +name: tox |
2 | 2 |
|
3 |
| -on: [push] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - "[0-9]+.[0-9]+.x" |
| 8 | + tags: |
| 9 | + - "*" |
4 | 10 |
|
5 |
| -jobs: |
6 |
| - |
7 |
| - linters: |
8 |
| - |
9 |
| - runs-on: ubuntu-latest |
10 |
| - steps: |
11 |
| - - uses: actions/checkout@v2 |
12 |
| - - name: Setup Python |
13 |
| - uses: actions/setup-python@v1 |
14 |
| - with: |
15 |
| - python-version: 3.6 |
16 |
| - - name: Install Tox and any other packages |
17 |
| - run: pip install tox |
18 |
| - - name: Run Tox |
19 |
| - run: tox -e linters |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - master |
| 14 | + - "[0-9]+.[0-9]+.x" |
20 | 15 |
|
| 16 | +jobs: |
21 | 17 | build:
|
| 18 | + name: ${{ matrix.name }} |
| 19 | + runs-on: ${{ matrix.os }} |
22 | 20 |
|
23 |
| - runs-on: ubuntu-latest |
24 | 21 | strategy:
|
| 22 | + fail-fast: false |
25 | 23 | matrix:
|
26 |
| - python: [3.6, 3.7, 3.8] |
| 24 | + name: [ |
| 25 | + # "docs", |
| 26 | + "py36", |
| 27 | + "py37", |
| 28 | + "py38", |
| 29 | + "linters", |
| 30 | + "packaging", |
| 31 | + ] |
| 32 | + os: [ |
| 33 | + "ubuntu-latest", |
| 34 | + ] |
| 35 | + |
| 36 | + include: |
| 37 | + |
| 38 | + # - name: docs |
| 39 | + # python: "3.6" |
| 40 | + # os: ubuntu-latest |
| 41 | + # tox_env: docs |
| 42 | + - name: py36 |
| 43 | + python: "3.6" |
| 44 | + os: ubuntu-latest |
| 45 | + tox_env: py36 |
| 46 | + - name: py37 |
| 47 | + python: "3.7" |
| 48 | + os: ubuntu-latest |
| 49 | + tox_env: py37 |
| 50 | + - name: py38 |
| 51 | + python: "3.8" |
| 52 | + os: ubuntu-latest |
| 53 | + tox_env: py38 |
| 54 | + |
| 55 | + - name: "linters" |
| 56 | + python: "3.7" |
| 57 | + os: ubuntu-latest |
| 58 | + tox_env: "linters" |
| 59 | + - name: "packaging" |
| 60 | + python: "3.7" |
| 61 | + os: ubuntu-latest |
| 62 | + tox_env: "packaging" |
27 | 63 |
|
28 | 64 | steps:
|
29 |
| - - uses: actions/checkout@v2 |
30 |
| - - name: Setup Python |
| 65 | + - uses: actions/checkout@v1 |
| 66 | + - name: Set up Python ${{ matrix.python }} |
31 | 67 | uses: actions/setup-python@v1
|
32 | 68 | with:
|
33 | 69 | python-version: ${{ matrix.python }}
|
34 |
| - - name: Install Tox and any other packages |
35 |
| - run: pip install tox |
36 |
| - - name: Run Tox |
37 |
| - run: tox -e py # Run tox using the version of Python in `PATH` |
| 70 | + - name: Install dependencies |
| 71 | + run: | |
| 72 | + python -m pip install --upgrade pip |
| 73 | + pip install tox |
| 74 | + - name: Test |
| 75 | + run: "tox -e ${{ matrix.tox_env }}" |
| 76 | + |
| 77 | + publish: |
| 78 | + name: Publish to PyPI registry |
| 79 | + needs: |
| 80 | + - build |
| 81 | + runs-on: ubuntu-latest |
| 82 | + |
| 83 | + env: |
| 84 | + PY_COLORS: 1 |
| 85 | + TOXENV: packaging |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Switch to using Python 3.6 by default |
| 89 | + uses: actions/setup-python@v2 |
| 90 | + with: |
| 91 | + python-version: 3.6 |
| 92 | + - name: Install tox |
| 93 | + run: python -m pip install --user tox |
| 94 | + - name: Check out src from Git |
| 95 | + uses: actions/checkout@v2 |
| 96 | + with: |
| 97 | + # Get shallow Git history (default) for tag creation events |
| 98 | + # but have a complete clone for any other workflows. |
| 99 | + # Both options fetch tags but since we're going to remove |
| 100 | + # one from HEAD in non-create-tag workflows, we need full |
| 101 | + # history for them. |
| 102 | + fetch-depth: >- |
| 103 | + ${{ |
| 104 | + ( |
| 105 | + github.event_name == 'create' && |
| 106 | + github.event.ref_type == 'tag' |
| 107 | + ) && |
| 108 | + 1 || 0 |
| 109 | + }} |
| 110 | + - name: Drop Git tags from HEAD for non-tag-create events |
| 111 | + if: >- |
| 112 | + github.event_name != 'create' || |
| 113 | + github.event.ref_type != 'tag' |
| 114 | + run: >- |
| 115 | + git tag --points-at HEAD |
| 116 | + | |
| 117 | + xargs git tag --delete |
| 118 | + - name: Build dists |
| 119 | + run: python -m tox |
| 120 | + - name: Publish to test.pypi.org |
| 121 | + if: >- |
| 122 | + ( |
| 123 | + github.event_name == 'push' && |
| 124 | + github.ref == format( |
| 125 | + 'refs/heads/{0}', github.event.repository.default_branch |
| 126 | + ) |
| 127 | + ) || |
| 128 | + ( |
| 129 | + github.event_name == 'create' && |
| 130 | + github.event.ref_type == 'tag' |
| 131 | + ) |
| 132 | + uses: pypa/gh-action-pypi-publish@master |
| 133 | + with: |
| 134 | + password: ${{ secrets.testpypi_password }} |
| 135 | + repository_url: https://test.pypi.org/legacy/ |
| 136 | + - name: Publish to pypi.org |
| 137 | + if: >- # "create" workflows run separately from "push" & "pull_request" |
| 138 | + github.event_name == 'create' && |
| 139 | + github.event.ref_type == 'tag' |
| 140 | + uses: pypa/gh-action-pypi-publish@master |
| 141 | + with: |
| 142 | + password: ${{ secrets.pypi_password }} |
0 commit comments