3535 - name : Install dependencies
3636 run : |
3737 python -m pip install --upgrade pip
38- pip install build twine wheel setuptools bumpversion ruff
38+ pip install build twine wheel setuptools ruff
3939 pip install -r requirements.txt
4040 if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
4141
@@ -51,19 +51,67 @@ jobs:
5151 run : |
5252 pytest
5353
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
55101 run : |
56102 git config --local user.email "[email protected] " 57103 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 }}"
59107
60108 - name : Build package
61109 run : |
62110 python -m build
63111
64112 - name : Upload to PyPI
65113 env :
66- TWINE_USERNAME : ${{ secrets.PYPI_USERNAME }}
114+ TWINE_USERNAME : __token__
67115 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
68116 run : |
69117 twine upload dist/*
77125 if : ${{ github.event.inputs.create_release == 'true' }}
78126 uses : softprops/action-gh-release@v1
79127 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 }}
82130 generate_release_notes : true
0 commit comments