-
-
Notifications
You must be signed in to change notification settings - Fork 18
77 lines (72 loc) · 2.37 KB
/
python-publish-pypi.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
name: Publish reolink_aio on PyPI
on:
release:
types: [published]
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-20.04
name: Verify Python build context
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Verify version
run: |
python -m pip install setuptools
setup_version="$(python setup.py -V)"
branch_version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}' )
if [ "${setup_version}" == "${branch_version}" ]; then
echo "Version of tag ${branch_version} matches with version of setup.py ${setup_version}"
else
echo "Version of tag ${branch_version} doesn't match with version of setup.py ${setup_version}"
exit 1
fi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pylint mypy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Analysing the code with pylint
run: |
pylint reolink_aio
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 reolink_aio --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 reolink_aio --count --exit-zero --max-line-length=175 --statistics
- name: Black formatting
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./reolink_aio"
- name: mypy type checking
run: |
mypy reolink_aio
build:
name: Build and publish PyPi package
needs: verify
runs-on: ubuntu-20.04
if: github.repository_owner == 'starkillerOG'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}