-
Notifications
You must be signed in to change notification settings - Fork 6
54 lines (45 loc) · 1.55 KB
/
publish-to-test-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
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on:
push:
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: |
VERSION_TAG=`echo ${GITHUB_REF_NAME} \
| sed -r 's#v([0-9]+\.[0-9]\.[0-9])#\1#g' \
| sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "tag version = $VERSION_TAG"
VERSION_FILE=$(cat VERSION.txt)
echo "file version = $VERSION_FILE"
if [ "$VERSION_TAG" != "$VERSION_FILE" ]; then
echo "Version in file 'version.py' must be the same as the pushed tag"
exit 1
fi
python -m build --sdist --wheel --outdir dist/
# make this available for test
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN_V2 }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN_V2 }}