From e8655fb09d93a6add68c2ae69fffd7010614cd53 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Mon, 23 Dec 2024 10:08:11 +0100 Subject: [PATCH 1/2] Development: Add a script to automatically increase the version number --- README.md | 2 +- update_version.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 update_version.sh diff --git a/README.md b/README.md index a636026b314d..4088deb2c491 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ Refer to [Using JHipster in production](http://www.jhipster.tech/production) for The following command can automate the deployment to a server. The example shows the deployment to the main Artemis test server (which runs a virtual machine): ```shell -./artemis-server-cli deploy username@artemistest.ase.in.tum.de -w build/libs/Artemis-7.8.0.war +./artemis-server-cli deploy username@artemis-test0.artemis.in.tum.de -w build/libs/Artemis-7.8.0.war ``` ## Architecture diff --git a/update_version.sh b/update_version.sh new file mode 100644 index 000000000000..10980bb4737b --- /dev/null +++ b/update_version.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# Script to update version in specified files and locations +# Usage: ./update_version.sh [major|minor|bugfix] + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 [major|minor|bugfix]" + exit 1 +fi + +INCREMENT_TYPE=$1 + +# Validate the argument +if [[ "$INCREMENT_TYPE" != "major" && "$INCREMENT_TYPE" != "minor" && "$INCREMENT_TYPE" != "bugfix" ]]; then + echo "Error: Invalid argument. Use one of [major, minor, bugfix]. No other values are allowed." + exit 1 +fi + +# Function to increment version +increment_version() { + local version=$1 + local type=$2 + + IFS='.' read -r major minor bugfix <<< "$version" + + case $type in + major) + major=$((major + 1)) + minor=0 + bugfix=0 + ;; + minor) + minor=$((minor + 1)) + bugfix=0 + ;; + bugfix) + bugfix=$((bugfix + 1)) + ;; + esac + + echo "$major.$minor.$bugfix" +} + +# Read the current version from the first valid `version = "x.y.z"` in build.gradle +CURRENT_VERSION=$(awk -F'"' '/^version = "[0-9]+\.[0-9]+\.[0-9]+"/ {print $2; exit}' build.gradle) + +if [[ -z "$CURRENT_VERSION" ]]; then + echo "Could not find a valid version in build.gradle." + exit 1 +fi + +# Get the new version +NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$INCREMENT_TYPE") + +# Update files +echo "Updating version from $CURRENT_VERSION to $NEW_VERSION..." + +# Update build.gradle +sed -i '' "s/^version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" build.gradle + +# Update package.json to only update the version when the previous line is `"name": "artemis"` +awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" ' + BEGIN {found_name = 0} + /"name": "artemis"/ {found_name = 1} + found_name && /"version": ".*"/ { + sub("\"version\": \"" old_version "\"", "\"version\": \"" new_version "\"") + found_name = 0 + } + {print} +' package.json > package.json.tmp && mv package.json.tmp package.json + +# Update package-lock.json to only update the version when the previous line is `"name": "artemis"` +awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" ' + BEGIN {found_name = 0} + /"name": "artemis"/ {found_name = 1} + found_name && /"version": ".*"/ { + sub("\"version\": \"" old_version "\"", "\"version\": \"" new_version "\"") + found_name = 0 + } + {print} +' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json + +# Update README.md +sed -i '' "s/Artemis-$CURRENT_VERSION.war/Artemis-$NEW_VERSION.war/" README.md + +# Add changes to git and commit +echo "Staging changes for git..." +git add build.gradle package.json README.md package-lock.json + +echo "Creating git commit..." +git commit -m "Development: Bump version to $NEW_VERSION ($INCREMENT_TYPE update)" + +echo "Version update and git commit complete. New version: $NEW_VERSION" From 97c0636c961496fbce9a679a75a8e26358af315d Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Mon, 23 Dec 2024 10:25:52 +0100 Subject: [PATCH 2/2] Development: Bump version to 7.8.1 (bugfix update) --- README.md | 2 +- build.gradle | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4088deb2c491..14970443fb21 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ Refer to [Using JHipster in production](http://www.jhipster.tech/production) for The following command can automate the deployment to a server. The example shows the deployment to the main Artemis test server (which runs a virtual machine): ```shell -./artemis-server-cli deploy username@artemis-test0.artemis.in.tum.de -w build/libs/Artemis-7.8.0.war +./artemis-server-cli deploy username@artemis-test0.artemis.in.tum.de -w build/libs/Artemis-7.8.1.war ``` ## Architecture diff --git a/build.gradle b/build.gradle index d0e176d5c0f2..8447fced1b2b 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ plugins { } group = "de.tum.cit.aet.artemis" -version = "7.8.0" +version = "7.8.1" description = "Interactive Learning with Individual Feedback" java { diff --git a/package-lock.json b/package-lock.json index baf633322027..cee87b1beaf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "artemis", - "version": "7.8.0", + "version": "7.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "artemis", - "version": "7.8.0", + "version": "7.8.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 20521b08d96c..cc14577f03c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "artemis", - "version": "7.8.0", + "version": "7.8.1", "description": "Interactive Learning with Individual Feedback", "private": true, "license": "MIT",