Skip to content

Commit

Permalink
Automatically generates next release version
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Apr 3, 2024
1 parent 03b1f71 commit a776fc3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
24 changes: 24 additions & 0 deletions .github/scripts/next-version.sh
Original file line number Diff line number Diff line change
@@ -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 <version>"
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

13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'
Expand All @@ -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:
Expand All @@ -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: |
Expand Down

0 comments on commit a776fc3

Please sign in to comment.