From 9689af4d3a945997c13cb1853b60d6fdda0095bc Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Mar 2026 14:17:27 +0100 Subject: [PATCH] Add: Automatische Versionierung via VERSION-Datei - VERSION-Datei als Single Source of Truth (startet bei 1.5.1) - CI liest Version aus Datei statt hardcoded - Patch-Version wird nach Deploy automatisch gebumpt - Commit mit [skip ci] verhindert Endlosschleife --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++--- Dockerfile | 2 +- VERSION | 1 + web/src/App.tsx | 2 +- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 VERSION diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de9c1eb..3f116f2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - deploy + - bump-version variables: INTERNAL_REGISTRY: "192.168.1.100:9080" @@ -30,18 +31,19 @@ docker-build: EOF script: - | + VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") + if [ "$CI_COMMIT_REF_NAME" = "main" ]; then TAG="main" - VERSION="1.5.0" CHANNEL="stable" elif [ "$CI_COMMIT_REF_NAME" = "feature/nightly" ] || [ "$CI_COMMIT_REF_NAME" = "nightly" ]; then TAG="nightly" - VERSION="1.5.0-nightly" + VERSION="${VERSION}-nightly" CHANNEL="nightly" else CLEAN_TAG=$(echo "$CI_COMMIT_REF_NAME" | sed 's/\//-/g') TAG="$CLEAN_TAG" - VERSION="1.5.0-dev" + VERSION="${VERSION}-dev" CHANNEL="dev" fi @@ -101,3 +103,29 @@ deploy: -v /mnt/cache/appdata/dockge/container/jukebox/sounds/:/data/sounds:rw \ "$DEPLOY_IMAGE" - docker ps --filter name="$CONTAINER_NAME" --format "ID={{.ID}} Status={{.Status}} Image={{.Image}}" + +bump-version: + stage: bump-version + image: alpine:latest + needs: [deploy] + rules: + - if: $CI_COMMIT_BRANCH == "main" && $CI_COMMIT_MESSAGE !~ /\[skip ci\]/ + script: + - apk add --no-cache git + - | + VERSION=$(cat VERSION) + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + NEXT_PATCH=$((PATCH + 1)) + NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" + + echo "$NEXT_VERSION" > VERSION + echo "Bumped version: $VERSION -> $NEXT_VERSION" + + git config user.name "GitLab CI" + git config user.email "ci@adriahub.de" + git remote set-url origin "http://oauth2:${CI_PUSH_TOKEN}@192.168.1.100:9080/${CI_PROJECT_PATH}.git" + git add VERSION + git commit -m "v${NEXT_VERSION} [skip ci]" + git push origin HEAD:main diff --git a/Dockerfile b/Dockerfile index 22986c7..15b7255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ COPY web/package*.json ./ RUN npm install --no-audit --no-fund COPY web/ . ARG VITE_BUILD_CHANNEL=stable -ARG VITE_APP_VERSION=1.5.0 +ARG VITE_APP_VERSION=dev ENV VITE_BUILD_CHANNEL=$VITE_BUILD_CHANNEL ENV VITE_APP_VERSION=$VITE_APP_VERSION RUN npm run build diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8e03717 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.5.1 \ No newline at end of file diff --git a/web/src/App.tsx b/web/src/App.tsx index f951ef7..85b43f2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -92,7 +92,7 @@ export default function App() { return () => { es?.close(); clearTimeout(retryTimer); }; }, []); - const version = (import.meta as any).env?.VITE_APP_VERSION ?? '1.5.0'; + const version = (import.meta as any).env?.VITE_APP_VERSION ?? 'dev'; // Listen for Electron auto-update events useEffect(() => {