This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new ae8a83673c chore: Added a ram-check for Dockers memory settings to 
steo 0 and an auto-update NOTICE file's year to step 1
ae8a83673c is described below

commit ae8a83673cf8061570d2c501269ef0dc673bde7d
Author: Christofer Dutz <[email protected]>
AuthorDate: Wed Apr 9 22:53:36 2025 +0200

    chore: Added a ram-check for Dockers memory settings to steo 0 and an 
auto-update NOTICE file's year to step 1
---
 tools/release-0-update-generated-code.sh | 61 +++++++++++++++++++++++-----
 tools/release-1-create-branch.sh         | 68 +++++++++++++++++++++++++++-----
 2 files changed, 109 insertions(+), 20 deletions(-)

diff --git a/tools/release-0-update-generated-code.sh 
b/tools/release-0-update-generated-code.sh
index 9c7fbebcab..08f60e87d7 100755
--- a/tools/release-0-update-generated-code.sh
+++ b/tools/release-0-update-generated-code.sh
@@ -21,18 +21,50 @@
 
 DIRECTORY=..
 
-# 0. Check if there are uncommitted changes as these would automatically be 
committed (local)
+########################################################################################################################
+# 0. Check Docker Memory Availability
+########################################################################################################################
+
+# Minimum required memory in bytes (12 GB)
+REQUIRED_MEM=$((12 * 1024 * 1024 * 1024))
+
+# Extract total memory from `docker system info`
+TOTAL_MEM=$(docker system info --format '{{.MemTotal}}')
+
+# Check if TOTAL_MEM was retrieved successfully
+if [[ -z "$TOTAL_MEM" || "$TOTAL_MEM" -eq 0 ]]; then
+    echo "❌ Unable to determine total Docker memory. Is Docker running?"
+    exit 1
+fi
+
+# Compare and exit if not enough memory
+if (( TOTAL_MEM < REQUIRED_MEM )); then
+    echo "❌ Docker runtime has insufficient memory: $(awk "BEGIN {printf 
\"%.2f\", $TOTAL_MEM/1024/1024/1024}") GB"
+    echo "   At least 12 GB is required. Aborting."
+    exit 1
+fi
+
+########################################################################################################################
+# 1. Check if there are uncommitted changes as these would automatically be 
committed (local)
+########################################################################################################################
+
 if [[ $(git status --porcelain) ]]; then
   # Changes
-  echo "There are untracked files or changed files, aborting."
+  echo "❌ There are untracked files or changed files, aborting."
   exit 1
 fi
 
-# 1. Delete the pre-exising "out" directory that contains the maven local repo 
and deployments (local)
+########################################################################################################################
+# 2. Delete the pre-exising "out" directory that contains the maven local repo 
and deployments (local)
+########################################################################################################################
+
 echo "Deleting the maven local repo and previous deployments"
 rm -r $DIRECTORY/out
 
-# 2. Delete all generated sources (local)
+########################################################################################################################
+# 3. Delete all generated sources (local)
+########################################################################################################################
+
 echo "Deleting generated-sources:"
 find "$DIRECTORY" -path "*/src/main/generated" -print0 | while IFS= read -r -d 
'' f; do
     echo " - Deleting: $f"
@@ -45,20 +77,29 @@ rm -r "$DIRECTORY/plc4c/generated-sources"
 
 # TODO: Possibly check, if the year in the NOTICE is outdated
 
-# 3. Run the maven build for all modules with "update-generated-code" enabled 
(Docker container)
+########################################################################################################################
+# 4. Run the maven build for all modules with "update-generated-code" enabled 
(Docker container)
+########################################################################################################################
+
 docker compose build
 if ! docker compose run releaser bash /ws/mvnw -e -P 
with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code
 -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests; then
-    echo "Got non-0 exit code from docker compose, aborting."
+    echo "❌ Got non-0 exit code from docker compose, aborting."
     exit 1
 fi
 
-# 4. Make sure the generated driver documentation is up-to-date.
+########################################################################################################################
+# 5. Make sure the generated driver documentation is up-to-date.
+########################################################################################################################
+
 if ! docker compose run releaser bash /ws/mvnw -e -P with-java 
-Dmaven.repo.local=/ws/out/.repository clean site -pl :plc4j-driver-all; then
-    echo "Got non-0 exit code from docker compose, aborting."
+    echo "❌ Got non-0 exit code from docker compose, aborting."
     exit 1
 fi
 
-# Check if there is unchanged files (or committing and pushing nothing will 
fail) (local)
+########################################################################################################################
+# 6. Commit and push any changed files
+########################################################################################################################
+
 if [[ $(git status --porcelain) ]]; then
   echo "Committing changes."
   git add --all
@@ -68,4 +109,4 @@ else
   echo "No changes."
 fi
 
-echo "Pre-release updates complete. Please continue with 
'release-1-create-branch.sh' next."
\ No newline at end of file
+echo "✅ Pre-release updates complete. Please continue with 
'release-1-create-branch.sh' next."
\ No newline at end of file
diff --git a/tools/release-1-create-branch.sh b/tools/release-1-create-branch.sh
index cf5ea7c033..bc2a989147 100755
--- a/tools/release-1-create-branch.sh
+++ b/tools/release-1-create-branch.sh
@@ -21,14 +21,20 @@
 
 DIRECTORY=$(pwd)
 
+########################################################################################################################
 # 0. Check if there are uncommitted changes as these would automatically be 
committed (local)
+########################################################################################################################
+
 if [[ $(git status --porcelain) ]]; then
   # Changes
-  echo "There are untracked files or changed files, aborting."
+  echo "❌ There are untracked files or changed files, aborting."
   exit 1
 fi
 
+########################################################################################################################
 # 1. Get and calculate the current version (local)
+########################################################################################################################
+
 PROJECT_VERSION=$(../mvnw -f ../pom.xml -q -Dexec.executable=echo 
-Dexec.args="\${project.version}" --non-recursive exec:exec)
 RELEASE_VERSION=${PROJECT_VERSION%"-SNAPSHOT"}
 RELEASE_SHORT_VERSION=${RELEASE_VERSION%".0"}
@@ -40,7 +46,31 @@ echo "Release Version: '$RELEASE_VERSION'"
 echo "Release Branch Name: '$BRANCH_NAME'"
 echo "New develop Version: '$NEW_VERSION'"
 
-# 2. Ask if the RELEASE_NOTES have been filled out at all (local)
+########################################################################################################################
+# 2. Make sure the NOTICE file has the current year in the second line
+########################################################################################################################
+
+NOTICE_FILE="../NOTICE"
+CURRENT_YEAR=$(date +%Y)
+EXPECTED="Copyright 2017-${CURRENT_YEAR} The Apache Software Foundation"
+
+# Extract the second line
+SECOND_LINE=$(sed -n '2p' "$NOTICE_FILE")
+
+if [[ "$SECOND_LINE" != "$EXPECTED" ]]; then
+    echo "✏️  Updating $NOTICE_FILE"
+
+    # Replace line 2 with the expected text
+    awk -v expected="$EXPECTED" 'NR==2 {$0=expected} {print}' "$NOTICE_FILE" > 
"$NOTICE_FILE.tmp" &&
+    mv "$NOTICE_FILE.tmp" "$NOTICE_FILE"
+else
+    echo "✅ $NOTICE_FILE is already up to date."
+fi
+
+########################################################################################################################
+# 3. Ask if the RELEASE_NOTES have been filled out at all (local)
+########################################################################################################################
+
 read -pr "Have the RELEASE_NOTES been updated for this version? (yes/no) " yn
 case $yn in
        yes ) echo continuing with the process;;
@@ -50,16 +80,25 @@ case $yn in
                exit 1;;
 esac
 
-# 3. Do a simple maven branch command with pushChanges=false
+########################################################################################################################
+# 4. Do a simple maven branch command with pushChanges=false
+########################################################################################################################
+
 if ! docker compose run releaser bash /ws/mvnw -e -P 
with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code
 -Dmaven.repo.local=/ws/out/.repository release:branch 
-DautoVersionSubmodules=true -DpushChanges=false 
-DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME"; then
-    echo "Got non-0 exit code from docker compose, aborting."
+    echo "❌ Got non-0 exit code from docker compose, aborting."
     exit 1
 fi
 
-# 4. Remove the "(Unreleased)" prefix from the current version of the 
RELEASE_NOTES file (local)
+########################################################################################################################
+# 5 Remove the "(Unreleased)" prefix from the current version of the 
RELEASE_NOTES file (local)
+########################################################################################################################
+
 sed -i '' "s/(Unreleased) Apache PLC4X $PROJECT_VERSION*/Apache PLC4X 
$RELEASE_VERSION/" ../RELEASE_NOTES
 
-# 5. Add a new section for the new version to the RELEASE_NOTES file (local)
+########################################################################################################################
+# 6. Add a new section for the new version to the RELEASE_NOTES file (local)
+########################################################################################################################
+
 NEW_HEADER="==============================================================\n\
 (Unreleased) Apache PLC4X $NEW_VERSION\n\
 ==============================================================\n\
@@ -78,14 +117,23 @@ Bug Fixes\n\
 echo NEW_VERSION
 sed -i '' "1s/.*/$NEW_HEADER/" ../RELEASE_NOTES
 
-# 6. Commit the change (local)
+########################################################################################################################
+# 7. Commit the change (local)
+########################################################################################################################
+
 git add --all
 git commit -m "chore: prepared the RELEASE_NOTES for the next version."
 
-# 7. Push the changes (local)
+########################################################################################################################
+# 8. Push the changes (local)
+########################################################################################################################
+
 git push
 
-# 8. Switch to the release branch (local)
+########################################################################################################################
+# 9. Switch to the release branch (local)
+########################################################################################################################
+
 git checkout "$BRANCH_NAME"
 
-echo "Release branch creation complete. We have switched the local branch to 
the release branch. Please continue with 'release-2-prepare-release.sh' as soon 
as the release branch is ready for being released."
\ No newline at end of file
+echo "✅ Release branch creation complete. We have switched the local branch to 
the release branch. Please continue with 'release-2-prepare-release.sh' as soon 
as the release branch is ready for being released."
\ No newline at end of file

Reply via email to