3535 - name : Install dependencies
3636 run : |
3737 python -m pip install --upgrade pip
38- pip install build twine wheel setuptools ruff black tomllib
38+ pip install build twine wheel setuptools ruff black
3939 pip install -r requirements.txt
4040 if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
4141
@@ -52,12 +52,60 @@ jobs:
5252 # run: |
5353 # pytest
5454
55- - name : Get project version
56- id : get_version
55+ - name : Calculate new version
56+ id : version
5757 run : |
58- VERSION=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
59- echo "version=$VERSION" >> $GITHUB_OUTPUT
60-
58+ # Get current version from pyproject.toml
59+ CURRENT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
60+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
61+
62+ # Parse version components
63+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
64+
65+ # Calculate new version based on release type
66+ case "${{ github.event.inputs.release_type }}" in
67+ "major")
68+ NEW_MAJOR=$((MAJOR + 1))
69+ NEW_MINOR=0
70+ NEW_PATCH=0
71+ ;;
72+ "minor")
73+ NEW_MAJOR=$MAJOR
74+ NEW_MINOR=$((MINOR + 1))
75+ NEW_PATCH=0
76+ ;;
77+ "patch")
78+ NEW_MAJOR=$MAJOR
79+ NEW_MINOR=$MINOR
80+ NEW_PATCH=$((PATCH + 1))
81+ ;;
82+ esac
83+
84+ NEW_VERSION="${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}"
85+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
86+ echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION"
87+
88+ - name : Update version files
89+ run : |
90+ CURRENT_VERSION="${{ steps.version.outputs.current_version }}"
91+ NEW_VERSION="${{ steps.version.outputs.new_version }}"
92+
93+ # Update pyproject.toml
94+ sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml
95+
96+ # Update __init__.py
97+ sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" stagehand/__init__.py
98+
99+ echo "Updated version to $NEW_VERSION in pyproject.toml and __init__.py"
100+
101+ - name : Commit version bump
102+ run : |
103+ git config --local user.email "action@github.com"
104+ git config --local user.name "GitHub Action"
105+ git add pyproject.toml stagehand/__init__.py
106+ git commit -m "Bump version to ${{ steps.version.outputs.new_version }}"
107+ git tag "v${{ steps.version.outputs.new_version }}"
108+
61109 - name : Build package
62110 run : |
63111 python -m build
@@ -69,10 +117,15 @@ jobs:
69117 run : |
70118 twine upload dist/*
71119
120+ - name : Push version bump
121+ run : |
122+ git push
123+ git push --tags
124+
72125 - name : Create GitHub Release
73126 if : ${{ github.event.inputs.create_release == 'true' }}
74127 uses : softprops/action-gh-release@v1
75128 with :
76- tag_name : v${{ steps.get_version .outputs.version }}
77- name : Release v${{ steps.get_version .outputs.version }}
129+ tag_name : v${{ steps.version .outputs.new_version }}
130+ name : Release v${{ steps.version .outputs.new_version }}
78131 generate_release_notes : true
0 commit comments