-
Notifications
You must be signed in to change notification settings - Fork 21
74 lines (67 loc) · 2.06 KB
/
python.yml
File metadata and controls
74 lines (67 loc) · 2.06 KB
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: Python package
on:
push:
branches:
- main
pull_request:
release:
types: [created]
env:
REGISTRY_NAME: ${{ vars.REGISTRY_NAME }}
REGISTRY_URI: ${{ vars.REGISTRY_URI }}
POETRY_VERSION: 2.2.1
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | POETRY_VERSION=$POETRY_VERSION python3 -
- name: Install dependencies
run: |
poetry install
- name: Test with pytest
run: |
poetry run pytest --cov=. --cov-report xml --cov-report html tests
- uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.python-version }}
path: htmlcov/
publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | POETRY_VERSION=$POETRY_VERSION python3 -
- name: Update version in pyproject.toml
run: |
echo $GITHUB_REF_NAME | sed 's/^v//' | xargs poetry version
- name: Install dependencies
run: |
poetry install
- name: Registry config
run: |
poetry config repositories.$REGISTRY_NAME $REGISTRY_URI
poetry config pypi-token.$REGISTRY_NAME $PYPI_TOKEN
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Publish package to pypi
run: |
poetry publish --build --repository $REGISTRY_NAME