@@ -4,6 +4,8 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
44on : push
55
66jobs :
7+ # try to build in every push
8+ # if fails, we should check if things are broken
79 build :
810 name : Build distribution 📦
911 runs-on : ubuntu-latest
3032 name : python-package-distributions
3133 path : dist/
3234
35+ # on tag, verify tag is {major}.{minor}.{bugfix}
36+ # to avoid pushing alpha/dev versions to pypi
3337 verify-tag :
3438 name : verify tag conforms
3539 if : startsWith(github.ref, 'refs/tags/')
4044 trimmed_tag=${GITHUB_REF#refs/tags/}
4145 echo trimmed_tag='"'$trimmed_tag'"'
4246 exit [[ "$trimmed_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
43-
47+
48+ # if both build and verify-tag passes
49+ # downloads build artefact
50+ # upload via twine
4451 publish-to-pypi :
4552 name : >-
4653 Publish Python 🐍 distribution 📦 to PyPI
@@ -49,16 +56,25 @@ jobs:
4956 - build
5057 - verify-tag
5158 runs-on : ubuntu-latest
52- environment :
53- name : pypi
54- url : https://pypi.org/p/ebrains-drive
55- permissions :
56- id-token : write # IMPORTANT: mandatory for trusted publishing
5759 steps :
60+ - uses : actions/checkout@v4
61+ - name : Set up Python
62+ uses : actions/setup-python@v5
63+ with :
64+ python-version : " 3.x"
65+ - name : " Setup twine to upload artefacts"
66+ run : |
67+ python -m pip install --user --upgrade twine
68+ echo "[pypi]" >~/.pypirc
69+ echo "username = __token__" >>~/.pypirc
70+ echo "password = ${{ secrets.PYPI_TOKEN_XG }}" >>~/.pypirc
71+
5872 - name : Download all the dists
5973 uses : actions/download-artifact@v4
6074 with :
6175 name : python-package-distributions
6276 path : dist/
63- - name : Publish distribution 📦 to PyPI
64- uses : pypa/gh-action-pypi-publish@release/v1
77+ - name : Publish distribution 📦 to PyPI (by twine)
78+ run : |
79+ echo "Uploading to pypi"
80+ python -m twine upload dist/*
0 commit comments