Skip to content

Commit b7bf3cb

Browse files
authored
Automatically calculate next version (#746)
1 parent d480af1 commit b7bf3cb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/prepare_release.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
inputs:
1010
version:
1111
description: New version number (e.g. '1.2.3' without the 'v' prefix)
12-
required: true
1312

1413
jobs:
1514
prepare_release:
@@ -37,19 +36,32 @@ jobs:
3736
with:
3837
node-version: 14
3938

39+
- name: Calculate version
40+
id: get_version
41+
run: |
42+
if [ "${VERSION}" = "" ] ; then
43+
LATEST_TAG=$(git describe --tags --abbrev=0)
44+
NEXT_TAG=$(echo ${LATEST_TAG#v} | awk '{split($0, a, "."); print a[1] "." a[2] + 1 "." a[3]}')
45+
echo ::set-output name=version::$NEXT_TAG
46+
else
47+
echo ::set-output name=version::$VERSION
48+
fi
49+
env:
50+
VERSION: ${{ github.event.inputs.version }}
51+
4052
- name: Bump version
4153
run: |
4254
git switch -c "release/${RELEASE_VERSION}"
4355
npm version --allow-same-version --no-git-tag-version "${RELEASE_VERSION}"
4456
git commit --allow-empty -a -m "Bump version to ${RELEASE_VERSION}"
4557
git push -f --set-upstream origin "release/${RELEASE_VERSION}"
4658
env:
47-
RELEASE_VERSION: ${{ github.event.inputs.version }}
59+
RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
4860

4961
- name: Create PR
5062
uses: actions/github-script@v5
5163
env:
52-
RELEASE_VERSION: ${{ github.event.inputs.version }}
64+
RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
5365
BASE: ${{ github.event.ref }}
5466
with:
5567
github-token: ${{ steps.get_token.outputs.token }}

0 commit comments

Comments
 (0)