Skip to content

Commit d0af65a

Browse files
committed
update release
1 parent 71be0d8 commit d0af65a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ name: Release
22

33
on:
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

616
permissions:
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

Comments
 (0)