Skip to content

Commit 8bdb788

Browse files
committed
ci: Add git hash to TestPyPI version to enable unique package uploads
1 parent 177b1d1 commit 8bdb788

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/publish-to-pypi.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,28 @@ jobs:
5959
id-token: write
6060

6161
steps:
62+
- uses: actions/checkout@v4
6263
- name: Download all the dists
6364
uses: actions/download-artifact@v4
6465
with:
6566
name: python-package-distributions
6667
path: dist/
68+
- name: Install Python
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: "3.x"
72+
- name: Update version with git hash
73+
run: |
74+
pip install wheel
75+
HASH=$(git rev-parse --short HEAD)
76+
for wheel in dist/*.whl; do
77+
NEW_WHEEL=$(echo $wheel | sed "s/-\([0-9.]*\)-/-\1.dev${HASH}-/")
78+
mv "$wheel" "$NEW_WHEEL"
79+
done
80+
for sdist in dist/*.tar.gz; do
81+
NEW_SDIST=$(echo $sdist | sed "s/-\([0-9.]*\)\./-\1.dev${HASH}./")
82+
mv "$sdist" "$NEW_SDIST"
83+
done
6784
- name: Publish distribution 📦 to TestPyPI
6885
uses: pypa/gh-action-pypi-publish@release/v1
6986
with:

0 commit comments

Comments
 (0)