Skip to content

Commit 75b80cc

Browse files
committed
added the commit sha to the generated preview version to ensure uniqueness.
1 parent c7b4914 commit 75b80cc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/pr-preview.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,28 @@ jobs:
1515
- name: Set preview version
1616
run: |
1717
BASE_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
18-
echo "VERSION=${BASE_VERSION}.dev${GITHUB_PR_NUMBER}" >> $GITHUB_ENV
18+
SHORT_SHA=$(git rev-parse --short HEAD)
19+
echo "VERSION=${BASE_VERSION}.dev${GITHUB_PR_NUMBER}+${SHORT_SHA}" >> $GITHUB_ENV
20+
21+
- name: Check if version exists on Test PyPI
22+
id: version_check
23+
run: |
24+
if pip index versions --index-url https://test.pypi.org/simple/ socketsecurity | grep -q "${VERSION}"; then
25+
echo "Version ${VERSION} already exists on Test PyPI"
26+
echo "exists=true" >> $GITHUB_OUTPUT
27+
else
28+
echo "Version ${VERSION} not found on Test PyPI"
29+
echo "exists=false" >> $GITHUB_OUTPUT
30+
fi
1931
2032
- name: Build package
33+
if: steps.version_check.outputs.exists != 'true'
2134
run: |
2235
pip install build
2336
python -m build
2437
2538
- name: Publish to Test PyPI
39+
if: steps.version_check.outputs.exists != 'true'
2640
uses: pypa/[email protected]
2741
with:
2842
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)