File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish Python distributions to PyPI or TestPyPI
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ version :
6+ description : ' Version upload to pypi'
7+ required : true
8+ pypi_repo :
9+ description : ' Upload to testpypi or pypi'
10+ default : ' testpypi'
11+ required : true
12+
13+ jobs :
14+ publish :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@master
18+ with :
19+ ref : ${{ github.event.inputs.version }}
20+ - uses : actions/setup-python@v3
21+ with :
22+ python-version : ' 3.9'
23+ - name : Check distribution version
24+ run : |
25+ v=$(python setup.py --version)
26+ if [[ $v != ${{ github.event.inputs.version }} ]]; then
27+ echo "ERROR: Package version $v is not same as input version ${{ github.event.inputs.version }}."
28+ echo "Update package version, tag the commit and rerun this workflow."
29+ exit 1
30+ fi
31+ - name : Install pypa/build
32+ run : >-
33+ python -m
34+ pip install
35+ build
36+ --user
37+ - name : Build a binary wheel and a source tarball
38+ run : >-
39+ python -m
40+ build
41+ --sdist
42+ --wheel
43+ --outdir dist/
44+ .
45+ - name : Publish distribution to TestPyPI
46+ if : ${{ github.event.inputs.pypi_repo == 'testpypi' }}
47+ uses : pypa/gh-action-pypi-publish@master
48+ with :
49+ user : __token__
50+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
51+ repository_url : https://test.pypi.org/legacy/
52+ - name : Publish distribution to PyPI
53+ if : ${{ github.event.inputs.pypi_repo == 'pypi' }}
54+ uses : pypa/gh-action-pypi-publish@master
55+ with :
56+ user : __token__
57+ password : ${{ secrets.PYPI_API_TOKEN }}
You can’t perform that action at this time.
0 commit comments