-
Notifications
You must be signed in to change notification settings - Fork 16
66 lines (64 loc) · 2 KB
/
publish-to-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
name: publish-to-pypi
on:
push:
tags:
- v*
env:
PYTHON_VERSION: '3.7'
jobs:
test:
name: Run tests and and publish to Test PyPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
pip install -r requirements.txt
- name: Run tests
run: python -m tox -e pytest
- name: Update dev version
run: |
ver=$(grep 'version\s=' setup.cfg | grep -o '[^ ]*$')
dev_ver=${ver%.*}.dev$(date +%Y%m%d%H%M%S)
sed -i "s/$ver/$dev_ver/g" setup.cfg
- name: Generate distribution archives
run: python -m tox -e build-dist
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: http://test.pypi.org/legacy/
if: success()
publish:
needs: test
name: Publish package to PyPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
pip install -r requirements.txt
- name: Update version to tag
run: |
ver=$(grep 'version\s=' setup.cfg | grep -o '[^ ]*$')
tag=${GITHUB_REF##*/}
sed -i "s/$ver/$tag/g" setup.cfg
- name: Generate distribution archives
run: python -m tox -e build-dist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
if: success()