already set next version

This commit is contained in:
2026-02-05 14:37:20 +01:00
parent 6943e678a9
commit 3d0a1b86de
5 changed files with 55 additions and 6 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import (
) )
// Version is the application version // Version is the application version
const Version = "0.2.3" const Version = "0.2.4"
var ( var (
// GitCommit will be set by build flags or detected at runtime // GitCommit will be set by build flags or detected at runtime
+1 -1
View File
@@ -1,6 +1,6 @@
# Frontend Version Management # Frontend Version Management
## Current Version: 0.2.2 ## Current Version: 0.2.3
The frontend version is managed independently from the backend. The frontend version is managed independently from the backend.
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "bamort-frontend", "name": "bamort-frontend",
"version": "0.2.2", "version": "0.2.3",
"private": true, "private": true,
"license": "SEE LICENSE IN LICENSE", "license": "SEE LICENSE IN LICENSE",
"type": "module", "type": "module",
+1 -1
View File
@@ -1,5 +1,5 @@
// Frontend version information // 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 // Git commit will be injected at build time or detected from env
export const GIT_COMMIT = import.meta.env.VITE_GIT_COMMIT || 'unknown' export const GIT_COMMIT = import.meta.env.VITE_GIT_COMMIT || 'unknown'
+51 -2
View File
@@ -10,14 +10,16 @@ BACKEND_VERSION_MD="backend/VERSION.md"
FRONTEND_VERSION_MD="frontend/VERSION.md" FRONTEND_VERSION_MD="frontend/VERSION.md"
usage() { 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 <version> Update backend version" echo " -b <version> Update backend version"
echo " -f <version> Update frontend version" echo " -f <version> Update frontend version"
echo " -n Bump patch version based on current files"
echo " -c Commit using versions from files" echo " -c Commit using versions from files"
echo " -t Tag using versions from files" echo " -t Tag using versions from files"
echo "Examples:" echo "Examples:"
echo " $0 -b 0.1.31 -f 0.2.0" echo " $0 -b 0.1.31 -f 0.2.0"
echo " $0 -b 0.1.31 -c -t" echo " $0 -b 0.1.31 -c -t"
echo " $0 -n -c"
echo " $0 -c -t" 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." 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 exit 1
@@ -37,10 +39,23 @@ read_frontend_version() {
sed -n "s/.*export const VERSION = '\(.*\)'.*/\1/p" "$FRONTEND_VERSION_FILE" | head -n1 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="" BACKEND_VERSION_ARG=""
FRONTEND_VERSION_ARG="" FRONTEND_VERSION_ARG=""
DO_COMMIT=false DO_COMMIT=false
DO_TAG=false DO_TAG=false
BUMP_PATCH=false
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
@@ -62,6 +77,10 @@ while [ $# -gt 0 ]; do
DO_TAG=true DO_TAG=true
shift shift
;; ;;
-n)
BUMP_PATCH=true
shift
;;
-h|--help) -h|--help)
usage usage
;; ;;
@@ -71,10 +90,40 @@ while [ $# -gt 0 ]; do
esac esac
done 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 usage
fi 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 [ -n "$BACKEND_VERSION_ARG" ]; then
if [ -f "$BACKEND_VERSION_FILE" ]; then if [ -f "$BACKEND_VERSION_FILE" ]; then
sed -i "s/const Version = \"[^\"]*\"/const Version = \"$BACKEND_VERSION_ARG\"/" "$BACKEND_VERSION_FILE" sed -i "s/const Version = \"[^\"]*\"/const Version = \"$BACKEND_VERSION_ARG\"/" "$BACKEND_VERSION_FILE"