File tree Expand file tree Collapse file tree 2 files changed +44
-8
lines changed
Expand file tree Collapse file tree 2 files changed +44
-8
lines changed Original file line number Diff line number Diff line change 77 inputs :
88 version :
99 required : true
10- description : " Version to bump `package.json` to (format: x.y.z)"
10+ type : choice
11+ description : " What type of release is this"
12+ options :
13+ - " major"
14+ - " minor"
15+ - " patch"
1116
1217jobs :
1318 create-release-pr :
@@ -31,20 +36,24 @@ jobs:
3136 git config --global user.email "github-actions@github.com"
3237 git config --global user.name "GitHub Actions"
3338
34- git checkout -b release/ ${{ inputs.version }}
39+ NEW_VERSION=$(./scripts/workflows/increment-version.sh ${{ inputs.version }})
3540
36- npm version ${{ inputs.version }} --no-git-tag-version
41+ git checkout -b release/$NEW_VERSION
42+
43+ npm version $NEW_VERSION --no-git-tag-version
3744 git add package.json package-lock.json
38- git commit -m "Release extension version ${{ inputs.version }}"
45+ git commit -m "Release extension version $NEW_VERSION"
46+
47+ git push --set-upstream origin release/$NEW_VERSION
3948
40- git push --set-upstream origin release/${{ inputs.version }}
49+ echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
4150
4251 - name : Create PR
4352 run : |
4453 gh pr create \
45- --title "Release version ${{ inputs.version }}" \
46- --body "Release version ${{ inputs.version }}" \
54+ --title "Release version ${{ env.new_version }}" \
55+ --body "Release version ${{ env.new_version }}" \
4756 --base main \
48- --head release/${{ inputs.version }}
57+ --head release/${{ env.new_version }}
4958 env :
5059 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ VERSION=$( cat package.json | jq -r ' .version' )
4+
5+ echo " Current version: $VERSION "
6+ echo " Incrementing $1 version"
7+
8+ MAJOR=$( echo $VERSION | cut -d. -f1)
9+ MINOR=$( echo $VERSION | cut -d. -f2)
10+ PATCH=$( echo $VERSION | cut -d. -f3)
11+
12+ if [ " $1 " == " major" ]; then
13+ MAJOR=$(( MAJOR+ 1 ))
14+ MINOR=0
15+ PATCH=0
16+ elif [ " $1 " == " minor" ]; then
17+ MINOR=$(( MINOR+ 1 ))
18+ PATCH=0
19+ elif [ " $1 " == " patch" ]; then
20+ PATCH=$(( PATCH+ 1 ))
21+ else
22+ echo " Invalid version type. Use 'major', 'minor' or 'patch'"
23+ exit 1
24+ fi
25+
26+ NEW_VERSION=" $MAJOR .$MINOR .$PATCH "
27+ echo $NEW_VERSION
You can’t perform that action at this time.
0 commit comments