From 4803df3f9a7685a0750702c77fd2aa35f8fb603d Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Fri, 1 Mar 2024 12:08:27 +0100 Subject: [PATCH] start work on release pipeline --- .github/workflows/create-release-branch.yml | 76 +++++++++++++++++++++ pom.xml | 4 +- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/create-release-branch.yml diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml new file mode 100644 index 00000000..264b6471 --- /dev/null +++ b/.github/workflows/create-release-branch.yml @@ -0,0 +1,76 @@ +name: Create release branch + +on: + workflow_dispatch: + branches: [ develop ] + inputs: + release: + description: 'Type of the release.' + options: + - major + - minor + - patch + default: minor + +jobs: + create_branch: + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/develop' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Create version + run: | + CURRENT_VERSION=$(./mvnw -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec) + echo $CURRENT_VERSION + MAJOR=`echo $CURRENT_VERSION | cut -d. -f1` + MINOR=`echo $CURRENT_VERSION | cut -d. -f2` + PATCH=`echo $CURRENT_VERSION | cut -d. -f3 | cut -d- -f1` + + if [ ${{ inputs.release }} == 'major' ] + then + VERSION=${MAJOR+1}.0.0 + DEV_VERSION=${MAJOR}.1.0-SNAPSHOT + elif [ ${{ inputs.release }} == 'minor' ] + then + VERSION=${MAJOR}.${MINOR}.0 + DEV_VERSION=${MAJOR}.${MINOR+1}.0-SNAPSHOT + else + VERSION=${MAJOR}.${MINOR-1}.${PATCH+1} + DEV_VERSION=${MAJOR}.${MINOR}.0-SNAPSHOT + fi + echo $VERSION + + - name: Create release branch + run: | + git branch release/$VERSION + + mvn versions:set -DnewVersion=${VERSION}-SNAPSHOT versions:commit + git commit -am "updated project version to ${VERSION}" + + git push --set-upstream origin release/$VERSION + - name: Create branch to update develop version + run: | + git branch feature/update_develop_version_${DEV_VERSION} + + mvn versions:set -DnewVersion=${DEV_VERSION} versions:commit + git commit -am "updated development version to ${DEV_VERSION}" + + git push --set-upstream origin feature/update_develop_version_${DEV_VERSION} + + wrong_branch: + if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/develop' + + runs-on: ubuntu-latest + + steps: + - name: ERROR + run: echo 'This workflow only runs on develop branch!' diff --git a/pom.xml b/pom.xml index 0c70403c..98c70f47 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,8 @@ de.vitagroup.num-portal num-portal - 1.17.0 - + 1.17.0-SNAPSHOT + org.springframework.boot spring-boot-starter-parent