Skip to content

Commit e9b9919

Browse files
committed
Actually setting preview version in init
1 parent 75b80cc commit e9b9919

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/pr-preview.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
run: |
1717
BASE_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
1818
SHORT_SHA=$(git rev-parse --short HEAD)
19-
echo "VERSION=${BASE_VERSION}.dev${GITHUB_PR_NUMBER}+${SHORT_SHA}" >> $GITHUB_ENV
19+
PREVIEW_VERSION="${BASE_VERSION}.dev${GITHUB_PR_NUMBER}+${SHORT_SHA}"
20+
echo "VERSION=${PREVIEW_VERSION}" >> $GITHUB_ENV
21+
22+
# Temporarily update the version in __init__.py
23+
sed -i "s/__version__ = \"${BASE_VERSION}\"/__version__ = \"${PREVIEW_VERSION}\"/" socketsecurity/__init__.py
2024
2125
- name: Check if version exists on Test PyPI
2226
id: version_check
@@ -35,6 +39,12 @@ jobs:
3539
pip install build
3640
python -m build
3741
42+
- name: Restore original version
43+
if: always() # Run even if previous steps fail
44+
run: |
45+
BASE_VERSION=$(echo $VERSION | cut -d'.' -f1-3)
46+
sed -i "s/__version__ = \"${VERSION}\"/__version__ = \"${BASE_VERSION}\"/" socketsecurity/__init__.py
47+
3848
- name: Publish to Test PyPI
3949
if: steps.version_check.outputs.exists != 'true'
4050
uses: pypa/[email protected]

0 commit comments

Comments
 (0)