35
35
- name : Install dependencies
36
36
run : |
37
37
python -m pip install --upgrade pip
38
- pip install build twine wheel setuptools bumpversion ruff
38
+ pip install build twine wheel setuptools ruff
39
39
pip install -r requirements.txt
40
40
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
41
41
@@ -51,11 +51,59 @@ jobs:
51
51
run : |
52
52
pytest
53
53
54
- - name : Update version
54
+ - name : Calculate new version
55
+ id : version
56
+ run : |
57
+ # Get current version from pyproject.toml
58
+ CURRENT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
59
+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
60
+
61
+ # Parse version components
62
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
63
+
64
+ # Calculate new version based on release type
65
+ case "${{ github.event.inputs.release_type }}" in
66
+ "major")
67
+ NEW_MAJOR=$((MAJOR + 1))
68
+ NEW_MINOR=0
69
+ NEW_PATCH=0
70
+ ;;
71
+ "minor")
72
+ NEW_MAJOR=$MAJOR
73
+ NEW_MINOR=$((MINOR + 1))
74
+ NEW_PATCH=0
75
+ ;;
76
+ "patch")
77
+ NEW_MAJOR=$MAJOR
78
+ NEW_MINOR=$MINOR
79
+ NEW_PATCH=$((PATCH + 1))
80
+ ;;
81
+ esac
82
+
83
+ NEW_VERSION="${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}"
84
+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
85
+ echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION"
86
+
87
+ - name : Update version files
88
+ run : |
89
+ CURRENT_VERSION="${{ steps.version.outputs.current_version }}"
90
+ NEW_VERSION="${{ steps.version.outputs.new_version }}"
91
+
92
+ # Update pyproject.toml
93
+ sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml
94
+
95
+ # Update __init__.py
96
+ sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" stagehand/__init__.py
97
+
98
+ echo "Updated version to $NEW_VERSION in pyproject.toml and __init__.py"
99
+
100
+ - name : Commit version bump
55
101
run : |
56
102
git config --local user.email "[email protected] "
57
103
git config --local user.name "GitHub Action"
58
- bumpversion ${{ github.event.inputs.release_type }}
104
+ git add pyproject.toml stagehand/__init__.py
105
+ git commit -m "Bump version to ${{ steps.version.outputs.new_version }}"
106
+ git tag "v${{ steps.version.outputs.new_version }}"
59
107
60
108
- name : Build package
61
109
run : |
77
125
if : ${{ github.event.inputs.create_release == 'true' }}
78
126
uses : softprops/action-gh-release@v1
79
127
with :
80
- tag_name : v$(python setup.py -- version)
81
- name : Release v$(python setup.py -- version)
128
+ tag_name : v${{ steps. version.outputs.new_version }}
129
+ name : Release v${{ steps. version.outputs.new_version }}
82
130
generate_release_notes : true
0 commit comments