|
4 | 4 |
|
5 | 5 | # Get version from pyproject.toml |
6 | 6 | VERSION=$(grep "^version = " pyproject.toml | cut -d'"' -f2) |
| 7 | +TAG="v$VERSION" |
7 | 8 |
|
8 | | -echo "Publishing FastComments Python SDK v$VERSION..." |
| 9 | +echo "Publishing FastComments Python SDK $TAG..." |
9 | 10 |
|
10 | 11 | # Clean up old builds |
11 | 12 | echo "Cleaning up old builds..." |
12 | 13 | rm -rf dist/ build/ *.egg-info |
13 | 14 |
|
14 | | -# Build the package |
| 15 | +# Build the package (wheel + sdist) to attach to the GitHub Release |
15 | 16 | echo "Building the package..." |
16 | | -#python3 -m pip install --upgrade build twine |
| 17 | +#python3 -m pip install --upgrade build |
17 | 18 | python3 -m build |
18 | 19 |
|
19 | | -# Check the package |
20 | | -echo "Checking the package..." |
21 | | -python3 -m twine check dist/* |
22 | | - |
23 | 20 | echo "" |
24 | 21 | echo "Package built successfully!" |
25 | 22 | echo "" |
26 | 23 |
|
27 | | -# Publish to PyPI |
28 | | -echo "Publishing to PyPI..." |
29 | | -python3 -m twine upload dist/* |
| 24 | +# Tag the release (skip if the tag already exists) |
| 25 | +if git rev-parse "$TAG" >/dev/null 2>&1; then |
| 26 | + echo "Tag $TAG already exists, skipping tag creation." |
| 27 | +else |
| 28 | + echo "Tagging $TAG..." |
| 29 | + git tag "$TAG" |
| 30 | + git push origin "$TAG" |
| 31 | +fi |
| 32 | + |
| 33 | +# Create the GitHub Release with the built artifacts (skip if it already exists) |
| 34 | +if gh release view "$TAG" >/dev/null 2>&1; then |
| 35 | + echo "Release $TAG already exists; uploading/clobbering artifacts..." |
| 36 | + gh release upload "$TAG" dist/*.whl dist/*.tar.gz --clobber |
| 37 | +else |
| 38 | + echo "Creating GitHub Release $TAG..." |
| 39 | + gh release create "$TAG" dist/*.whl dist/*.tar.gz \ |
| 40 | + --title "$TAG" \ |
| 41 | + --notes "FastComments Python SDK $TAG" |
| 42 | +fi |
30 | 43 |
|
31 | 44 | echo "" |
32 | | -echo "✓ Published to PyPI!" |
| 45 | +echo "✓ Published GitHub Release $TAG!" |
33 | 46 | echo "Users can install it with:" |
34 | | -echo " pip install fastcomments" |
| 47 | +echo " pip install git+https://github.com/fastcomments/fastcomments-python.git@$TAG" |
0 commit comments