-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (50 loc) · 1.59 KB
/
main.yml
File metadata and controls
63 lines (50 loc) · 1.59 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
name: ci/cd
on: [push]
jobs:
test:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install ".[dev]"
- name: Analyse the code with black
run: black . --check --verbose --diff --color
- name: Analyse imports with isort
run: isort . --check --diff --color
- name: Run tests
run: python -m unittest discover -v -s tests
publish:
name: Upload to PyPi
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install toml
python -m pip install build
- name: Compare package version and git tag
run: |
TAG=$(git describe --tags --abbrev=0)
VERSION=$(python -c "import toml; import pathlib; print(toml.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")
[[ $TAG == $VERSION ]] && echo "VALID=true" >> "$GITHUB_ENV" || echo "VALID=false" >> "$GITHUB_ENV"
- name: Build
if: env.VALID == 'true'
run: python -m build
- name: Publish
if: env.VALID == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}