-
Notifications
You must be signed in to change notification settings - Fork 5
77 lines (66 loc) · 2.57 KB
/
python-app.yml
File metadata and controls
77 lines (66 loc) · 2.57 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
75
76
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python application
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Get current PyPI version
id: pypi_version
run: |
PYPI_VERSION=$(curl -Lsk https://pypi.org/pypi/github-utils-api/json | jq -r .info.version)
echo "Current PyPI version: $PYPI_VERSION"
echo "::set-output name=version::$PYPI_VERSION"
shell: bash
- name: Bump minor version
id: bump_minor_version
run: |
CURRENT_VERSION=${{ steps.pypi_version.outputs.version }}
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH_VERSION=$(echo $CURRENT_VERSION | cut -d. -f3)
NEW_MINOR_VERSION=$((MINOR_VERSION + 1))
NEW_VERSION="$MAJOR_VERSION.$NEW_MINOR_VERSION.$PATCH_VERSION"
echo "New version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
shell: bash
- name: Update setup.py
run: |
NEW_VERSION=${{ steps.bump_minor_version.outputs.new_version }}
sed -i "s/version=.*/version='$NEW_VERSION',/" setup.py
shell: bash
- name: Generating Artifacts
run: |
python setup.py sdist bdist_wheel
- name: pypi-publish
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
password: ${{ secrets.PYPI_API_TOKEN }}
if: github.event_name != 'pull_request'
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.3.1
with:
path: dist/
if: github.event_name != 'pull_request'