Bladeren bron

Add scripts and workflow to update Spring Boot version

Marcus Da Coregio 2 jaren geleden
bovenliggende
commit
a320504852

+ 1 - 1
.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
+        run: ./gradlew check --continue

+ 17 - 0
.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"

+ 20 - 0
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
+}

+ 14 - 0
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"

+ 1 - 0
versions.properties

@@ -0,0 +1 @@
+springBootVersion=3.1.1