Skip to content

Commit f4a97ce

Browse files
authored
update version updating yml
1 parent 157ac74 commit f4a97ce

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/release_pypi.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,29 @@ jobs:
3131
- name: Get version from pyproject.toml
3232
id: get_version
3333
run: |
34-
CURRENT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
34+
# First verify the file exists and extract version with error handling
35+
CURRENT_VERSION=$(python -c '
36+
import toml
37+
import sys
38+
try:
39+
config = toml.load("pyproject.toml")
40+
if "project" not in config:
41+
print("Error: Missing [project] section in pyproject.toml", file=sys.stderr)
42+
sys.exit(1)
43+
print(config["project"]["version"])
44+
except Exception as e:
45+
print(f"Error: {str(e)}", file=sys.stderr)
46+
sys.exit(1)
47+
')
48+
49+
# Store the version in GitHub Actions output
3550
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
3651
37-
# Split version into parts
52+
# Split version into major, minor, patch components
3853
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
3954
echo "major_version=${major}" >> $GITHUB_OUTPUT
4055
echo "minor_version=${minor}" >> $GITHUB_OUTPUT
41-
56+
4257
- name: Update version
4358
run: |
4459
set -e # Exit immediately if a command exits with a non-zero status

0 commit comments

Comments
 (0)