-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 1.83 KB
/
pypi_publish.yaml
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
name: PyPI Publish
on:
release:
types: [published]
jobs:
pypi-publish:
name: Publish tagged release on PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Verify Package Version vs Tag Version
run: |
PKG_VER="$(grep -oP 'version = "\K[^"]+' pyproject.toml)"
TAG_VER="${GITHUB_REF##*/}"
echo "Package version is $PKG_VER" >&2
echo "Tag version is $TAG_VER" >&2
if [ "$PKG_VER" != "$TAG_VER" ]; then
echo "Package version and tag name mismatch." >&2
exit 1
fi
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Install the newly build package with all extras
run: |
TAR_PATH="$( realpath ./dist/*.tar.gz)"
python -m \
pip install \
"${TAR_PATH}[all]"
- name: Install testing requirements
run: >-
python -m
pip install
-r requirements-dev.txt
- name: Run pytest on freshly installed package
run: |
pytest .
- name: Publish distribution package to PyPI (test)
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution package to PyPI (production)
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}