-
Notifications
You must be signed in to change notification settings - Fork 7
73 lines (67 loc) · 2.37 KB
/
build-and-publish.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
name: Build Test and Deploy (master)
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Lint code
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --show-source --statistics
mypy semversioner tests
- name: Build and test
run: |
pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install twine==4.0.2
pip install wheel==0.42.0
pip install semversioner==1.7.0
previous_version=$(semversioner current-version)
semversioner release
new_version=$(semversioner current-version)
semversioner changelog > CHANGELOG.md
echo "Replace version '$previous_version' to '$new_version' in __version__.py ..."
echo "__version__ = '$new_version'" > semversioner/__version__.py
python setup.py sdist bdist_wheel
twine upload dist/*
git config --global user.name 'Semversioner Bot'
git config --global user.email '[email protected]'
git add .
git commit -m "Update files for new version '${new_version}' [skip ci]"
git push origin master
git tag -a -m "Tagging for release ${new_version}" "${new_version}"
git push origin ${new_version}