1
- # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
1
name : Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
3
2
4
- on : push
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ workflow_dispatch :
8
+ inputs :
9
+ publish_to_pypi :
10
+ description : " Publish to PyPI"
11
+ required : true
12
+ default : " false"
5
13
6
14
jobs :
7
15
build-n-publish :
8
-
9
16
name : Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
10
17
runs-on : ubuntu-latest
11
18
steps :
12
- - uses : actions/checkout@master
13
- - name : Set up Python 3.9
14
- uses : actions/setup-python@v1
15
- with :
16
- python-version : 3.9
17
- - name : Install pypa/build
18
- run : >-
19
- python -m
20
- pip install
21
- build
22
- --user
23
- - name : Build a binary wheel and a source tarball
24
- run : >-
25
- python -m
26
- build
27
- --sdist
28
- --wheel
29
- --outdir dist/
30
- .
31
- - name : Publish distribution 📦 to Test PyPI
32
- uses : pypa/gh-action-pypi-publish@master
33
- with :
34
- skip_existing : true
35
- user : __token__
36
- password : ${{ secrets.TESTNET_PYPI_API_TOKEN }}
37
- repository_url : https://test.pypi.org/legacy/
38
- - name : Publish distribution 📦 to PyPI
39
- if : startsWith(github.ref, 'refs/tags')
40
- uses : pypa/gh-action-pypi-publish@master
41
- with :
42
- user : __token__
43
- password : ${{ secrets.PYPI_API_TOKEN }}
19
+ - uses : actions/checkout@master
20
+ - name : Set up Python 3.9
21
+ uses : actions/setup-python@v1
22
+ with :
23
+ python-version : 3.9
24
+ - name : Install pypa/build
25
+ run : >
26
+ python -m
27
+ pip install
28
+ build
29
+ --user
30
+ - name : Build a binary wheel and a source tarball
31
+ run : >
32
+ python -m
33
+ build
34
+ --sdist
35
+ --wheel
36
+ --outdir dist/
37
+ .
38
+ - name : Publish distribution 📦 to Test PyPI
39
+ uses : pypa/gh-action-pypi-publish@master
40
+ with :
41
+ skip_existing : true
42
+ user : __token__
43
+ password : ${{ secrets.TESTNET_PYPI_API_TOKEN }}
44
+ repository_url : https://test.pypi.org/legacy/
45
+ - name : Publish distribution 📦 to PyPI
46
+ if : startsWith(github.ref, 'refs/tags') || github.event.inputs.publish_to_pypi == 'true'
47
+ uses : pypa/gh-action-pypi-publish@master
48
+ with :
49
+ user : __token__
50
+ password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments