-
Notifications
You must be signed in to change notification settings - Fork 5
57 lines (56 loc) · 1.67 KB
/
publish_pypi.yml
File metadata and controls
57 lines (56 loc) · 1.67 KB
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
name: Build and publish Python distributions to PyPI or TestPyPI
on:
workflow_dispatch:
inputs:
version:
description: 'Version upload to pypi'
required: true
pypi_repo:
description: 'Upload to testpypi or pypi'
default: 'testpypi'
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
ref: ${{ github.event.inputs.version }}
- uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Check distribution version
run: |
v=$(python setup.py --version)
if [[ $v != ${{ github.event.inputs.version }} ]]; then
echo "ERROR: Package version $v is not same as input version ${{ github.event.inputs.version }}."
echo "Update package version, tag the commit and rerun this workflow."
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: Publish distribution to TestPyPI
if: ${{ github.event.inputs.pypi_repo == 'testpypi' }}
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: ${{ github.event.inputs.pypi_repo == 'pypi' }}
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}