@@ -2,6 +2,16 @@ name: Release
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ bump :
7+ description : ' Version bump type'
8+ required : true
9+ default : ' patch'
10+ type : choice
11+ options :
12+ - patch
13+ - minor
14+ - major
515
616permissions :
717 contents : write
@@ -21,18 +31,23 @@ jobs:
2131 git config user.name "github-actions[bot]"
2232 git config user.email "github-actions[bot]@users.noreply.github.com"
2333
24- - name : Sync versions and tag
34+ - name : Bump version and sync
2535 id : sync
2636 run : |
27- VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
37+ CURRENT=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
38+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
39+ case "${{ inputs.bump }}" in
40+ major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
41+ minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
42+ patch) PATCH=$((PATCH + 1)) ;;
43+ esac
44+ VERSION="${MAJOR}.${MINOR}.${PATCH}"
2845 echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
2946 bash scripts/version-sync.sh "$VERSION"
30- if ! git diff --quiet; then
31- git add Cargo.toml npm/ pypi/
32- git commit -m "v$VERSION: sync package versions"
33- fi
47+ git add Cargo.toml npm/ pypi/
48+ git commit -m "v$VERSION: bump and sync package versions"
3449 if git rev-parse "v$VERSION" >/dev/null 2>&1; then
35- echo "::error::Tag v$VERSION already exists. Bump the version in Cargo.toml before releasing. "
50+ echo "::error::Tag v$VERSION already exists."
3651 exit 1
3752 fi
3853 git tag "v$VERSION"
0 commit comments