Automatically calculate next version
@@ -9,7 +9,6 @@ on:
inputs:
version:
description: New version number (e.g. '1.2.3' without the 'v' prefix)
- required: true
jobs:
prepare_release:
@@ -29,6 +28,19 @@ jobs:
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
+ - name: Calculate version
+ id: get_version
+ run: |
+ if [ "${VERSION}" = "" ] ; then
+ LATEST_TAG=$(git describe --tags --abbrev=0)
+ NEXT_TAG=$(echo ${LATEST_TAG#v} | awk '{split($0, a, "."); print a[1] "." a[2] + 1 "." a[3]}')
+ echo ::set-output name=version::$NEXT_TAG
+ else
+ echo ::set-output name=version::$VERSION
+ fi
+ env:
+ VERSION: ${{ github.event.inputs.version }}
+
- name: Bump version
run: |
git switch -c "release/${RELEASE_VERSION}"
@@ -36,12 +48,12 @@ jobs:
git commit -a -m "Version bump ${RELEASE_VERSION}"
git push -f --set-upstream origin "release/${RELEASE_VERSION}"
env:
- RELEASE_VERSION: ${{ github.event.inputs.version }}
+ RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
- name: Create PR
uses: actions/github-script@v5
env:
- RELEASE_VERSION: ${{ github.event.inputs.version }}
+ RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
BASE: ${{ github.event.ref }}
with:
github-token: ${{ steps.get_token.outputs.token }}
