1919 PREVIEW_VERSION="${BASE_VERSION}.dev${GITHUB_PR_NUMBER}+${SHORT_SHA}"
2020 echo "VERSION=${PREVIEW_VERSION}" >> $GITHUB_ENV
2121
22- # Temporarily update the version in __init__.py
23- sed -i "s/__version__ = \"${BASE_VERSION}\"/__version__ = \"${PREVIEW_VERSION}\"/" socketsecurity/__init__.py
22+ # Update version in __init__.py
23+ echo "__version__ = \"${PREVIEW_VERSION}\"" > socketsecurity/__init__.py.tmp
24+ cat socketsecurity/__init__.py | grep -v "__version__" >> socketsecurity/__init__.py.tmp
25+ mv socketsecurity/__init__.py.tmp socketsecurity/__init__.py
26+
27+ # Verify the change
28+ echo "Updated version in __init__.py:"
29+ cat socketsecurity/__init__.py | grep "__version__"
2430
2531 - name : Check if version exists on Test PyPI
2632 id : version_check
@@ -40,17 +46,20 @@ jobs:
4046 python -m build
4147
4248 - name : Restore original version
43- if : always() # Run even if previous steps fail
49+ if : always()
4450 run : |
4551 BASE_VERSION=$(echo $VERSION | cut -d'.' -f1-3)
46- sed -i "s/__version__ = \"${VERSION}\"/__version__ = \"${BASE_VERSION}\"/" socketsecurity/__init__.py
52+ echo "__version__ = \"${BASE_VERSION}\"" > socketsecurity/__init__.py.tmp
53+ cat socketsecurity/__init__.py | grep -v "__version__" >> socketsecurity/__init__.py.tmp
54+ mv socketsecurity/__init__.py.tmp socketsecurity/__init__.py
4755
4856 - name : Publish to Test PyPI
4957 if : steps.version_check.outputs.exists != 'true'
5058 uses : pypa/gh-action-pypi-publish@v1.8.11
5159 with :
5260 repository-url : https://test.pypi.org/legacy/
5361 password : ${{ secrets.TEST_PYPI_TOKEN }}
62+ verbose : true
5463
5564 - name : Comment on PR
5665 uses : actions/github-script@v7
0 commit comments