| 1 |
name: Python package |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: "*" |
| 6 |
tags: "*.*.*" |
| 7 |
pull_request: |
| 8 |
|
| 9 |
jobs: |
| 10 |
tests: |
| 11 |
runs-on: ${{ matrix.os }} |
| 12 |
strategy: |
| 13 |
matrix: |
| 14 |
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy3.9"] |
| 15 |
os: ["ubuntu-latest", "windows-latest"] |
| 16 |
|
| 17 |
steps: |
| 18 |
- uses: actions/checkout@v3 |
| 19 |
- name: Set up Python ${{ matrix.python-version }} |
| 20 |
uses: actions/setup-python@v4 |
| 21 |
with: |
| 22 |
python-version: ${{ matrix.python-version }} |
| 23 |
- name: Install dependencies |
| 24 |
run: | |
| 25 |
python -m pip install --upgrade pip |
| 26 |
pip install tox |
| 27 |
- name: Test with tox |
| 28 |
run: tox run -e py,report_ci,lint |
| 29 |
- uses: codecov/codecov-action@v3 |
| 30 |
with: |
| 31 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 32 |
|
| 33 |
package: |
| 34 |
runs-on: ubuntu-latest |
| 35 |
steps: |
| 36 |
- name: Checkout code |
| 37 |
uses: actions/checkout@v3 |
| 38 |
- name: Install build dependencies |
| 39 |
run: pip install --upgrade build |
| 40 |
- name: Build distributions |
| 41 |
run: python -m build |
| 42 |
- name: Upload packages |
| 43 |
uses: actions/upload-artifact@v3 |
| 44 |
with: |
| 45 |
name: python-dist |
| 46 |
path: dist/* |
| 47 |
retention-days: 1 |
| 48 |
|
| 49 |
publish: |
| 50 |
needs: [tests, package] |
| 51 |
runs-on: ubuntu-latest |
| 52 |
if: startsWith(github.ref, 'refs/tags/') |
| 53 |
environment: |
| 54 |
name: release |
| 55 |
url: https://pypi.org/p/pytest-console-scripts |
| 56 |
permissions: |
| 57 |
id-token: write |
| 58 |
steps: |
| 59 |
- name: Download packages |
| 60 |
uses: actions/download-artifact@v3 |
| 61 |
with: |
| 62 |
name: python-dist |
| 63 |
path: dist/ |
| 64 |
- name: Publish package distributions to PyPI |
| 65 |
uses: pypa/gh-action-pypi-publish@release/v1 |