generated from expobrain/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (72 loc) · 2.18 KB
/
main.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
name: Unit testing, formatting & linting
on: [push]
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache multiple paths
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.cache/pre-commit
key: ${{ runner.os }}-3.11-${{ hashFiles('**/.pre-commit-config.yaml') }}
- run: pip install pre-commit~=2.20
- run: pre-commit run -a
testing:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref_name }}-${{ matrix.python-version }}
cancel-in-progress: true
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache multiple Pips
uses: actions/cache@v4
with:
path: |
~/.cache/pip
.venv
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- run: pip install poetry~=1.3
- run: poetry config virtualenvs.in-project true
- run: poetry install --sync
- run: make test
- run: make mypy
publish_package:
runs-on: ubuntu-latest
needs:
- testing
- linting
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Cache Pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
.venv
key: ${{ runner.os }}-3.10-${{ hashFiles('**/poetry.lock') }}
- run: pip install poetry~=1.2
- run: poetry build
# From https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi-and-testpypi
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}