Skip to content

Commit

Permalink
Merge pull request #101 from Data-Simply/bugfix/version-bump
Browse files Browse the repository at this point in the history
version bump
  • Loading branch information
mayurkmmt authored Feb 21, 2025
2 parents d6d4261 + a5db4cf commit 39c79a0
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,34 @@ jobs:
uv sync
- name: Install Pre-commit in uv environment
run: uv run pip install pre-commit
- name: Bump Version Based on Release Type
- name: Install toml in uv environment
run: uv run pip install toml
- name: Bump Version
run: |
version=$(grep 'version' pyproject.toml | cut -d '"' -f2)
python << EOF
import toml
import sys
if [ "${{ inputs.release }}" == "major" ]; then
new_version=$(echo $version | awk -F. '{print $1+1 ".0.0"}')
elif [ "${{ inputs.release }}" == "minor" ]; then
new_version=$(echo $version | awk -F. '{print $1 "." $2+1 ".0"}')
elif [ "${{ inputs.release }}" == "patch" ]; then
new_version=$(echo $version | awk -F. '{print $1 "." $2 "." $3+1}')
fi
with open('pyproject.toml', 'r') as f:
config = toml.load(f)
echo "Bumping version to $new_version"
sed -i 's/version = "'"$version"'"/version = "'"$new_version"'"/' pyproject.toml
version = config['project']['version']
release = "${{ inputs.release }}"
major, minor, patch = map(int, version.split('.'))
if release == "major":
new_version = f"{major + 1}.0.0"
elif release == "minor":
new_version = f"{major}.{minor + 1}.0"
elif release == "patch":
new_version = f"{major}.{minor}.{patch + 1}"
config['project']['version'] = new_version
with open('pyproject.toml', 'w') as f:
toml.dump(config, f)
EOF
- name: Build package
run: python -m build
Expand Down

0 comments on commit 39c79a0

Please sign in to comment.