Skip to content

Commit 46d3251

Browse files
Antony BaileyAntony Bailey
authored andcommitted
attempt to improve security
1 parent 22b568b commit 46d3251

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/python-publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ jobs:
2626
python -m pip install --upgrade pip
2727
pip install build twine
2828
29+
- name: Set version from tag
30+
run: |
31+
# Extract tag name without 'v' prefix if present
32+
VERSION=${GITHUB_REF#refs/tags/}
33+
VERSION=${VERSION#v}
34+
# Update version in setup.py, pyproject.toml or __init__.py
35+
if [ -f "setup.py" ]; then
36+
sed -i "s/version=['\"][^'\"]*['\"]/version='${VERSION}'/g" setup.py
37+
fi
38+
if [ -f "pyproject.toml" ]; then
39+
sed -i "s/version = \"[^\"]*\"/version = \"${VERSION}\"/g" pyproject.toml
40+
fi
41+
if [ -f "__init__.py" ]; then
42+
sed -i "s/__version__ = ['\"][^'\"]*['\"]/__version__ = '${VERSION}'/g" __init__.py
43+
fi
44+
2945
- name: Build package
3046
run: python -m build
3147

0 commit comments

Comments
 (0)