Skip to content

Commit 54e3779

Browse files
authored
Merge pull request #45 from HumanBrainProject/cicd/publishViaTwine
cicd: publish pypi via twine
2 parents c9821fe + 45554ad commit 54e3779

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

.github/workflows/publish.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
44
on: push
55

66
jobs:
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
@@ -30,6 +32,8 @@ jobs:
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/')
@@ -40,7 +44,10 @@ jobs:
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

Comments
 (0)