19
19
PREVIEW_VERSION="${BASE_VERSION}.dev${GITHUB_PR_NUMBER}+${SHORT_SHA}"
20
20
echo "VERSION=${PREVIEW_VERSION}" >> $GITHUB_ENV
21
21
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__"
24
30
25
31
- name : Check if version exists on Test PyPI
26
32
id : version_check
@@ -40,17 +46,20 @@ jobs:
40
46
python -m build
41
47
42
48
- name : Restore original version
43
- if : always() # Run even if previous steps fail
49
+ if : always()
44
50
run : |
45
51
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
47
55
48
56
- name : Publish to Test PyPI
49
57
if : steps.version_check.outputs.exists != 'true'
50
58
51
59
with :
52
60
repository-url : https://test.pypi.org/legacy/
53
61
password : ${{ secrets.TEST_PYPI_TOKEN }}
62
+ verbose : true
54
63
55
64
- name : Comment on PR
56
65
uses : actions/github-script@v7
0 commit comments