-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (46 loc) · 1.73 KB
/
minor_version_bump.yml
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
52
53
54
55
56
57
58
name: Update Minor Version on PR
on:
pull_request:
types:
- opened
jobs:
minor-version-bump:
runs-on: ubuntu-latest
steps:
- name: Set Git User Identity
env:
GH_EMAIL: ${{ secrets.GH_EMAIL }}
GH_USER: ${{ secrets.GH_USER }}
run: |
git config --global user.email "$GH_EMAIL"
git config --global user.name "$GH_USER"
- name: Checkout Repository
uses: actions/checkout@v3
- name: Check if Minor Version Needs Bump
id: check_minor_bump
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
MINOR_BUMP_FLAG="bump_minor_${BRANCH_NAME}"
if [ -z "$(git show-ref --heads "$MINOR_BUMP_FLAG")" ]; then
git checkout -b $BRANCH_NAME
git pull --rebase origin $BRANCH_NAME
# Parse the current version
CURRENT_VERSION=$(cat VERSION)
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
# Calculate the new version
NEW_MINOR=$((MINOR + 1))
NEW_VERSION="$MAJOR.$NEW_MINOR.0"
# Update the version file
echo "$NEW_VERSION" > VERSION
echo "Bumped version to $NEW_VERSION"
# Commit and push the changes
git commit -am "Bump version to $NEW_VERSION"
git push origin $BRANCH_NAME
# Set the new version as an output
echo "::set-output name=new_version::$NEW_VERSION"
else
echo "We already bumped minor for this branch"
fi