diff --git a/.github/scripts/next-version.sh b/.github/scripts/next-version.sh new file mode 100755 index 000000000..797a15036 --- /dev/null +++ b/.github/scripts/next-version.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Determines the next version of EqualsVerifier. +# If the version was x.y, the new version will be x.y.1-SNAPSHOT +# If the version was x.y.z, the new version will be x.y.(z+1)-SNAPSHOT + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +version="$1" +IFS='.' read -ra ADDR <<< "$version" + +if [ ${#ADDR[@]} -eq 2 ]; then + echo "$version.1-SNAPSHOT" +elif [ ${#ADDR[@]} -eq 3 ]; then + (( ADDR[2]++ )) + echo "${ADDR[0]}.${ADDR[1]}.${ADDR[2]}-SNAPSHOT" +else + echo "Error: Version format not supported." + exit 1 +fi + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2da64ff09..cfe8229df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,9 +6,6 @@ on: version: description: 'Release version' required: true - nextVersion: - description: 'Next version after release (-SNAPSHOT will be added automatically)' - required: true jobs: build: @@ -24,6 +21,10 @@ jobs: java-version: 21 distribution: temurin cache: maven + - name: 'Calculate next version' + run: echo "NEXT_VERSION=$(bash .github/scripts/next-version.sh ${{ github.event.inputs.version }})" >> "$GITHUB_ENV" + - name: 'Print version information' + run: echo -e "New version ${{ github.event.inputs.version }}\nNext version $NEXT_VERSION" - name: 'Set release version' run: mvn versions:set --no-transfer-progress --batch-mode -DnewVersion=${{ github.event.inputs.version }} - name: 'Update version in documentation' @@ -36,7 +37,7 @@ jobs: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} message: Bumps version to ${{ github.event.inputs.version }} - name: 'Stage release' - run: mvn clean deploy --no-transfer-progress --batch-mode -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy + run: mvn clean deploy --no-transfer-progress --batch-mode "-DaltDeploymentRepository=local::default::file://$(pwd)/target/staging-deploy" - name: 'Run JReleaser' uses: jreleaser/release-action@v2 with: @@ -51,12 +52,12 @@ jobs: JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }} JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD }} - name: 'Set release version' - run: mvn versions:set --no-transfer-progress --batch-mode -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT + run: mvn versions:set --no-transfer-progress --batch-mode -DnewVersion="$NEXT_VERSION" - name: 'Commit & push changes' uses: actions-js/push@master with: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} - message: "Prepares for next development iteration: ${{ github.event.inputs.nextVersion }}-SNAPSHOT" + message: "Prepares for next development iteration: $NEXT_VERSION" tags: false - name: 'Print diagnostic information' run: |