Skip to content

Commit ac18fa2

Browse files
committed
Still working on the version handling
1 parent e9b9919 commit ac18fa2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/pr-preview.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ jobs:
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/[email protected]
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

Comments
 (0)