Skip to content

Commit 2d53ddf

Browse files
committed
fix(ci): publish Python wheel to GitHub Releases
GitHub Packages does not support PyPI registry, so twine upload with --skip-existing always failed. Replace with gh release create that uploads the built wheel as a GitHub Release asset. Install via: pip install https://github.com/selfpatch/ros2_medkit_clients/releases/download/py-v0.1.0/ros2_medkit_client-0.1.0-py3-none-any.whl Removes broken version-check job and twine dependency. Closes #9
1 parent b2b16b3 commit 2d53ddf

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/python-ci.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ jobs:
5959
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
6060
runs-on: ubuntu-latest
6161
permissions:
62-
packages: write
63-
contents: read
62+
contents: write
6463
defaults:
6564
run:
6665
working-directory: clients/python
@@ -77,7 +76,7 @@ jobs:
7776
node-version: '20'
7877

7978
- name: Install build tools
80-
run: pip install pipx build twine
79+
run: pip install pipx build
8180

8281
- name: Generate client from spec
8382
working-directory: .
@@ -89,8 +88,28 @@ jobs:
8988
- name: Build wheel
9089
run: python -m build
9190

92-
- name: Publish to GitHub Packages
93-
run: twine upload --skip-existing --repository-url https://pypi.pkg.github.com/selfpatch/ dist/*
91+
- name: Read version
92+
id: version
93+
run: |
94+
VERSION=$(python3 -c "
95+
import re, pathlib
96+
text = pathlib.Path('pyproject.toml').read_text()
97+
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.MULTILINE)
98+
print(m.group(1))
99+
")
100+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
101+
102+
- name: Publish wheel to GitHub Release
94103
env:
95-
TWINE_USERNAME: __token__
96-
TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
104+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
run: |
106+
TAG="py-v${{ steps.version.outputs.version }}"
107+
108+
# Delete existing release if same version (overwrite)
109+
gh release delete "$TAG" --yes 2>/dev/null || true
110+
111+
# Create release and upload wheel
112+
gh release create "$TAG" \
113+
--title "Python client v${{ steps.version.outputs.version }}" \
114+
--notes "Install: \`pip install https://github.com/selfpatch/ros2_medkit_clients/releases/download/${TAG}/$(ls dist/*.whl | head -1 | xargs basename)\`" \
115+
dist/*.whl

0 commit comments

Comments
 (0)