Skip to content

Commit 5b5552b

Browse files
committed
streamline workflow
1 parent 54cbd03 commit 5b5552b

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

.bumpversion.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[bumpversion]
2-
current_version = 0.3.8
2+
current_version = 0.0.1
33
commit = True
44
tag = True
55

6-
[bumpversion:file:setup.py]
7-
search = version="{current_version}"
8-
replace = version="{new_version}"
6+
[bumpversion:file:pyproject.toml]
7+
search = version = "{current_version}"
8+
replace = version = "{new_version}"
99

1010
[bumpversion:file:stagehand/__init__.py]
1111
search = __version__ = "{current_version}"

.github/workflows/publish.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
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,11 +51,59 @@ 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: |
@@ -77,6 +125,6 @@ jobs:
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

stagehand/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020
from .utils import configure_logging
2121

22-
__version__ = "0.3.9" #for pypi "stagehand"
22+
__version__ = "0.0.1"
2323

2424
__all__ = [
2525
"Stagehand",

0 commit comments

Comments
 (0)