Skip to content

Commit 8180775

Browse files
authored
Automatically calculate next version (#1082)
1 parent 2251696 commit 8180775

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/prepare_release.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
inputs:
66
version:
77
description: New version number (e.g. '1.2.3' without the 'v' prefix)
8-
required: true
98

109
jobs:
1110
prepare_release:
@@ -18,10 +17,24 @@ jobs:
1817
with:
1918
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
2019
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
20+
21+
- name: Calculate version
22+
id: get_version
23+
run: |
24+
if [ "${VERSION}" = "" ] ; then
25+
LATEST_TAG=$(git describe --tags --abbrev=0)
26+
NEXT_TAG=$(echo ${LATEST_TAG} | awk '{split($0, a, "."); print a[1] "." a[2] + 1 "." a[3]}')
27+
echo ::set-output name=version::$NEXT_TAG
28+
else
29+
echo ::set-output name=version::$VERSION
30+
fi
31+
env:
32+
VERSION: ${{ github.event.inputs.version }}
33+
2134
- name: Create PR
2235
uses: actions/github-script@v5
2336
env:
24-
RELEASE_VERSION: ${{ github.event.inputs.version }}
37+
RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
2538
with:
2639
github-token: ${{ steps.get_token.outputs.token }}
2740
script: |

0 commit comments

Comments
 (0)