-
Notifications
You must be signed in to change notification settings - Fork 90
79 lines (75 loc) · 2.27 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: CI/CD
on:
push:
pull_request:
jobs:
lint:
name: Lint
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install tox
run: pip install tox
- name: Run pycodestyle
run: tox
env:
TOXENV: pycodestyle
test:
name: Test Python ${{ matrix.python }} on ${{ matrix.os }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10', '3.11', '3.12']
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: pip install tox
- name: Compute TOXENV
id: toxenv
run: echo "toxenv=py$(tr -d . <<< ${{ matrix.python }})" >> $GITHUB_OUTPUT
shell: bash
- name: Run tests
run: tox
env:
TOXENV: ${{ steps.toxenv.outputs.toxenv }}
- name: Upload coverage to Codecov
if: ${{ !(github.event_name == 'push' && github.event.repository.fork) }}
uses: codecov/codecov-action@v3
with:
env_vars: OS,PYTHON
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
publish:
name: Publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !github.event.repository.fork
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create package
run: python setup.py sdist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}