From a3205048529d7cc712e049c9aa0f3ef3a6e45474 Mon Sep 17 00:00:00 2001 From: Marcus Da Coregio Date: Thu, 20 Jul 2023 10:27:37 -0300 Subject: [PATCH] Add scripts and workflow to update Spring Boot version --- .../continuous-integraion-workflow.yml | 2 +- .../workflows/update-spring-boot-version.yml | 17 ++++++++++++++++ find-latest-minor-version.sh | 20 +++++++++++++++++++ update-spring-boot-version.sh | 14 +++++++++++++ versions.properties | 1 + 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-spring-boot-version.yml create mode 100755 find-latest-minor-version.sh create mode 100755 update-spring-boot-version.sh create mode 100644 versions.properties diff --git a/.github/workflows/continuous-integraion-workflow.yml b/.github/workflows/continuous-integraion-workflow.yml index 8f769d7..41d155f 100644 --- a/.github/workflows/continuous-integraion-workflow.yml +++ b/.github/workflows/continuous-integraion-workflow.yml @@ -23,4 +23,4 @@ jobs: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - name: Build with Gradle - run: ./gradlew check --continue \ No newline at end of file + run: ./gradlew check --continue diff --git a/.github/workflows/update-spring-boot-version.yml b/.github/workflows/update-spring-boot-version.yml new file mode 100644 index 0000000..1561283 --- /dev/null +++ b/.github/workflows/update-spring-boot-version.yml @@ -0,0 +1,17 @@ +name: Update Spring Boot Version + +on: + workflow_dispatch: + schedule: + - cron: '0 12 * * *' # Once per day at 12am UTC + +jobs: + update-spring-boot-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update Spring Boot Version + run: ./upgrade-spring-boot-version.sh + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Update Spring Boot Version" diff --git a/find-latest-minor-version.sh b/find-latest-minor-version.sh new file mode 100755 index 0000000..f323ba8 --- /dev/null +++ b/find-latest-minor-version.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +increment_version() { + local version="$1" + local last_digit=$(echo "$version" | rev | cut -d '.' -f 1 | rev) + local incremented_digit=$((last_digit + 1)) + echo "${version%.*}.$incremented_digit" +} + +find_next_minor_version() { + local current_version=$1 + local maven_url=$2 + local next_version=$(increment_version "$current_version") + local url="$maven_url/$next_version/" + local response=$(curl --write-out "%{http_code}\n" --silent --output /dev/null "$url") + + if [ "$response" -eq 200 ]; then + echo "$next_version" + fi +} diff --git a/update-spring-boot-version.sh b/update-spring-boot-version.sh new file mode 100755 index 0000000..2fc0f29 --- /dev/null +++ b/update-spring-boot-version.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source ./find-latest-minor-version.sh +source ./versions.properties + +next_minor_version=$(find_next_minor_version "$springBootVersion" "https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter") + +if [ -z "$next_minor_version" ]; then + echo "No new minor Spring Boot version found" + exit 0 +fi + +sed -i '' -e "s/^\(springBootVersion\s*=\s*\).*$/\1$next_minor_version/" versions.properties +bash ./sync-boot-version.sh "$next_minor_version" diff --git a/versions.properties b/versions.properties new file mode 100644 index 0000000..c0abe9b --- /dev/null +++ b/versions.properties @@ -0,0 +1 @@ +springBootVersion=3.1.1