diff --git a/backend/appsystem/version.go b/backend/appsystem/version.go index 98655bf..c7658e2 100644 --- a/backend/appsystem/version.go +++ b/backend/appsystem/version.go @@ -5,7 +5,7 @@ import ( ) // Version is the application version -const Version = "0.2.3" +const Version = "0.2.4" var ( // GitCommit will be set by build flags or detected at runtime diff --git a/frontend/VERSION.md b/frontend/VERSION.md index 78c7a87..9ee6a4b 100644 --- a/frontend/VERSION.md +++ b/frontend/VERSION.md @@ -1,6 +1,6 @@ # Frontend Version Management -## Current Version: 0.2.2 +## Current Version: 0.2.3 The frontend version is managed independently from the backend. diff --git a/frontend/package.json b/frontend/package.json index 1018dc2..2c766d5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bamort-frontend", - "version": "0.2.2", + "version": "0.2.3", "private": true, "license": "SEE LICENSE IN LICENSE", "type": "module", diff --git a/frontend/src/version.js b/frontend/src/version.js index 8d9986e..896d8a6 100644 --- a/frontend/src/version.js +++ b/frontend/src/version.js @@ -1,5 +1,5 @@ // Frontend version information -export const VERSION = '0.2.2' +export const VERSION = '0.2.3' // Git commit will be injected at build time or detected from env export const GIT_COMMIT = import.meta.env.VITE_GIT_COMMIT || 'unknown' diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 31223d6..a154292 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -10,14 +10,16 @@ BACKEND_VERSION_MD="backend/VERSION.md" FRONTEND_VERSION_MD="frontend/VERSION.md" usage() { - echo "Usage: $0 [-b backend_version] [-f frontend_version] [-c] [-t]" + echo "Usage: $0 [-b backend_version] [-f frontend_version] [-n] [-c] [-t]" echo " -b Update backend version" echo " -f Update frontend version" + echo " -n Bump patch version based on current files" echo " -c Commit using versions from files" echo " -t Tag using versions from files" echo "Examples:" echo " $0 -b 0.1.31 -f 0.2.0" echo " $0 -b 0.1.31 -c -t" + echo " $0 -n -c" echo " $0 -c -t" echo "So you can set the version at any time, commit later without worrying about commit messages and tag later when merged into main." exit 1 @@ -37,10 +39,23 @@ read_frontend_version() { sed -n "s/.*export const VERSION = '\(.*\)'.*/\1/p" "$FRONTEND_VERSION_FILE" | head -n1 } +bump_patch() { + local ver="$1" + + if [[ "$ver" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + local major="${BASH_REMATCH[1]}" + local minor="${BASH_REMATCH[2]}" + local patch="${BASH_REMATCH[3]}" + patch=$((patch + 1)) + echo "${major}.${minor}.${patch}" + fi +} + BACKEND_VERSION_ARG="" FRONTEND_VERSION_ARG="" DO_COMMIT=false DO_TAG=false +BUMP_PATCH=false while [ $# -gt 0 ]; do case "$1" in @@ -62,6 +77,10 @@ while [ $# -gt 0 ]; do DO_TAG=true shift ;; + -n) + BUMP_PATCH=true + shift + ;; -h|--help) usage ;; @@ -71,10 +90,40 @@ while [ $# -gt 0 ]; do esac done -if [ -z "$BACKEND_VERSION_ARG" ] && [ -z "$FRONTEND_VERSION_ARG" ] && [ "$DO_COMMIT" = false ] && [ "$DO_TAG" = false ]; then +if [ -z "$BACKEND_VERSION_ARG" ] && [ -z "$FRONTEND_VERSION_ARG" ] && [ "$DO_COMMIT" = false ] && [ "$DO_TAG" = false ] && [ "$BUMP_PATCH" = false ]; then usage fi +if [ "$BUMP_PATCH" = true ]; then + BACKEND_VERSION_CURRENT=$(read_backend_version) + FRONTEND_VERSION_CURRENT=$(read_frontend_version) + + if [ -z "$BACKEND_VERSION_CURRENT" ] && [ -z "$FRONTEND_VERSION_CURRENT" ]; then + echo "❌ Cannot bump: version files missing" >&2 + exit 1 + fi + + if [ -z "$BACKEND_VERSION_ARG" ] && [ -n "$BACKEND_VERSION_CURRENT" ]; then + NEXT_BACKEND_VERSION=$(bump_patch "$BACKEND_VERSION_CURRENT") + if [ -z "$NEXT_BACKEND_VERSION" ]; then + echo "❌ Cannot bump backend: invalid version format '$BACKEND_VERSION_CURRENT'" >&2 + exit 1 + fi + BACKEND_VERSION_ARG="$NEXT_BACKEND_VERSION" + echo "✓ Bumping backend version to $BACKEND_VERSION_ARG" + fi + + if [ -z "$FRONTEND_VERSION_ARG" ] && [ -n "$FRONTEND_VERSION_CURRENT" ]; then + NEXT_FRONTEND_VERSION=$(bump_patch "$FRONTEND_VERSION_CURRENT") + if [ -z "$NEXT_FRONTEND_VERSION" ]; then + echo "❌ Cannot bump frontend: invalid version format '$FRONTEND_VERSION_CURRENT'" >&2 + exit 1 + fi + FRONTEND_VERSION_ARG="$NEXT_FRONTEND_VERSION" + echo "✓ Bumping frontend version to $FRONTEND_VERSION_ARG" + fi +fi + if [ -n "$BACKEND_VERSION_ARG" ]; then if [ -f "$BACKEND_VERSION_FILE" ]; then sed -i "s/const Version = \"[^\"]*\"/const Version = \"$BACKEND_VERSION_ARG\"/" "$BACKEND_VERSION_FILE"