Repository navigation
89 lines (82 loc) · 3.18 KB
/
Copy pathpythonapp.yml
File metadata and controls
89 lines (82 loc) · 3.18 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
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
matrix:
python_version: [3.7,3.8]
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# 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: Test with pytest
run: |
pip install pytest pytest-cov
python -m pytest --cov=./
- name: Upload Code coverage
run: |
pip install codecov
codecov --token=$CODECOV_TOKEN
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
release:
needs: [build]
if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'skip cd')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Retrieving the Version
run: |
echo "Getting version from the setup.py file..."
ApplicationVersion=$(cat setup.py | grep version | cut -d '=' -f 2 | cut -d "'" -f 2)
echo "setup.py file version: $ApplicationVersion"
echo "Testing if this version already exists in GitHub..."
echo "Get the tags first..."
tags=$(curl https://api.github.com/repos/gcarrarom/kubeconfig-cleaner-cli/tags)
echo "check if there's a match on the version.."
Match=$(echo $tags | jq -r ".[] | select(.name == \"v$ApplicationVersion\")")
if [[ -z "$Match" ]]; then
echo "All good, this doesn't match any old versions"
else
echo "Nope, we have this already... try choosing another one ;)"
exit 100
fi
echo "Version to be used: $ApplicationVersion"
echo "::set-env name=RELEASE_VERSION::$ApplicationVersion"
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.RELEASE_VERSION }}
release_name: Release v${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
- name: Pip Upload
uses: onichandame/pip-upload-action@0.0.1
with:
username: gui.martins
password: ${{secrets.PYPI_PASS}}