1- name : CI & Publish to TestPyPI
2- run-name : Publish Package to TestPyPI
1+ name : Build & Publish to PyPI
2+ run-name : Publish Package to PyPI
33
44on :
55 push :
66 branches :
7- - main
7+ - release
88
9- env :
10- REPO_ALIAS : rz-sample
11- TEST_PYPI_URL : https://test.pypi.org/legacy/
9+ concurrency :
10+ group : pypi-publish
11+ cancel-in-progress : true
1212
1313jobs :
1414 lint :
2727 build-and-publish :
2828 needs : lint
2929 runs-on : ubuntu-latest
30+ permissions :
31+ id-token : write
32+ contents : read
3033 steps :
3134 - name : Checkout code
3235 uses : actions/checkout@v5
@@ -38,13 +41,14 @@ jobs:
3841
3942 - name : Install Poetry
4043 run : |
41- curl -sSL https://install.python-poetry.org | python3 -
44+ curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3
4245 echo "$HOME/.local/bin" >> $GITHUB_PATH
4346
4447 - name : Check if version exists
4548 id : check_version
4649 run : |
4750 # 1. Get metadata from pyproject.toml
51+ poetry install --no-interaction --no-root
4852 PACKAGE_NAME=$(poetry version | awk '{print $1}')
4953 PACKAGE_VERSION=$(poetry version --short)
5054
5357
5458 # 2. Check the SPECIFIC version JSON endpoint
5559 # We use the JSON API because it's reliable for bots
56- URL="https://test. pypi.org/pypi/$PACKAGE_NAME/$PACKAGE_VERSION/json"
60+ URL="https://pypi.org/pypi/$PACKAGE_NAME/$PACKAGE_VERSION/json"
5761 STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
5862
5963 if [ "$STATUS" == "200" ]; then
@@ -67,12 +71,12 @@ jobs:
6771 - name : Configure and Publish
6872 if : steps.check_version.outputs.should_publish == 'true'
6973 run : |
70- poetry config repositories.${{ env.REPO_ALIAS }} ${{ env.TEST_PYPI_URL }}
71- poetry config pypi-token.${{ env.REPO_ALIAS }} ${{ secrets.TEST_PYPI_TOKEN }}
72- poetry publish -r ${{ env.REPO_ALIAS }} - -build
74+ # poetry config repositories.${{ env.REPO_ALIAS }} ${{ env.PYPI_URL }}
75+ # poetry config pypi-token.${{ env.REPO_ALIAS }} ${{ secrets.PYPI_TOKEN }}
76+ poetry publish --build
7377
7478 # Add Success Summary
7579 NAME=${{ steps.check_version.outputs.pkg_name }}
7680 VER=${{ steps.check_version.outputs.pkg_ver }}
7781 echo "### ✅ Success: Published $NAME v$VER" >> $GITHUB_STEP_SUMMARY
78- echo "View your package on TestPyPI : [rz-sample](https://test. pypi.org/project/rz-sample /)" >> $GITHUB_STEP_SUMMARY
82+ echo "View your package on PyPI : [rz-sample](https://pypi.org/project/$NAME /)" >> $GITHUB_STEP_SUMMARY
0 commit comments