-
Notifications
You must be signed in to change notification settings - Fork 4
51 lines (49 loc) · 1.59 KB
/
bump-version-and-release.yml
File metadata and controls
51 lines (49 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Bump Version & Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type (major, minor, patch)"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version (pubspec)
run: |
BUMP_TYPE="${{ github.event.inputs.bump }}"
VERSION=$(grep '^version:' pubspec.yaml | head -n1 | awk '{print $2}' | cut -d'+' -f1)
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
if [ "$BUMP_TYPE" = "major" ]; then
MAJOR=$((MAJOR+1)); MINOR=0; PATCH=0
elif [ "$BUMP_TYPE" = "minor" ]; then
MINOR=$((MINOR+1)); PATCH=0
else
PATCH=$((PATCH+1))
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
yq e -i ".version = \"$NEW_VERSION\"" pubspec.yaml
echo "Bumped version to $NEW_VERSION"
- name: Commit and tag version bump
run: |
VERSION=$(grep '^version:' pubspec.yaml | head -n1 | awk '{print $2}')
git add pubspec.yaml
git commit -m "chore: bump version to $VERSION"
git tag v$VERSION
- name: Push changes and tag
run: |
git push origin HEAD:main
git push origin --tags