1- name : Build and upload to PyPI
1+ name : Build and upload to internal PyPI
22
33on :
44 workflow_dispatch : # run on request (no need for PR)
@@ -40,17 +40,22 @@ jobs:
4040 name : Publish package
4141 needs : [build_wheels, build_sdist]
4242 environment : pypi
43- runs-on : ubuntu-latest
43+ runs-on : [self-hosted, linux, x64, dev]
4444 permissions : write-all
4545 steps :
46+ - name : Set up Python
47+ uses : actions/setup-python@v4
48+ with :
49+ python-version : " 3.10"
50+ - name : Install dependencies
51+ run : python -m pip install twine
4652 - name : Download artifacts
4753 uses : actions/download-artifact@v3
4854 with :
4955 # unpacks default artifact into dist/
5056 # if `name: artifact` is omitted, the action will create extra parent dir
5157 name : artifact
5258 path : dist
53- # to determine where to publish the source distribution to PyPI or TestPyPI
5459 - name : Check tag
5560 id : check-tag
5661 uses : actions-ecosystem/action-regex-match@v2
@@ -66,15 +71,18 @@ jobs:
6671 tag : ${{ github.ref }}
6772 overwrite : true
6873 file_glob : true
69- - name : Publish package distributions to PyPI
70- if : ${{ steps.check-tag.outputs.match != '' }}
71- 72- with :
73- password : ${{ secrets.PYPI_API_TOKEN }}
74- - name : Publish package distributions to TestPyPI
75- if : ${{ steps.check-tag.outputs.match == '' }}
76- 77- with :
78- password : ${{ secrets.TESTPYPI_API_TOKEN }}
79- repository-url : https://test.pypi.org/legacy/
80- verbose : true
74+ - name : Check dist contents
75+ run : twine check dist/*
76+ - name : Publish package dist to internal PyPI
77+ run : |
78+ export no_proxy=${{ secrets.PYPI_HOST }}
79+ export REPOSITORY_URL=http://${{ secrets.PYPI_HOST }}:${{ secrets.PYPI_PORT }}
80+ twine upload --verbose --repository-url $REPOSITORY_URL dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}
81+ - name : Clean up dist
82+ if : ${{ always() }}
83+ run : |
84+ if OUTPUT=$(ls | grep -c dist)
85+ then
86+ echo "Cleaning up dist directory"
87+ rm -r dist
88+ fi
0 commit comments