-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (83 loc) · 2.5 KB
/
workflow.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Python CI/CD Workflow
on:
push:
branches:
- master
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.13.0-rc.2
- name: Install Dependencies
run: |
pip install -r requirements-dev.txt
pre-commit install
- name: Lint Code
run: pre-commit run --all-files
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.13.0-rc.2
- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run Tests
run: python -m unittest ntp_amplification_test.py
publish:
name: Check Version and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.13.0-rc.2
- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Get Current Version
id: current_version
run: |
version=$(python -c "exec(open('version.py').read()); print(__version__)")
echo "Current version: $version"
echo "::set-output name=VERSION::$version"
- name: Check if Version is Incremented
id: version_check
run: |
git fetch origin master
git checkout master
cur_version=$(python -c "exec(open('version.py').read()); print(__version__)")
echo "Main branch version: $cur_version"
if [ "$cur_version" = "$version" ]; then
echo "Version has not been incremented, exiting..."
exit 1
else
echo "Version is incremented, proceeding..."
fi
- name: Build Package
id: build
if: steps.version_check.outcome == 'success'
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
if: steps.build.outcome == 'success'
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
pip install twine
twine upload dist/* -u __token__ -p $PYPI_TOKEN