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
This commit is contained in:
Daniel 2026-03-07 14:17:27 +01:00
parent 7bebb7db9a
commit 9689af4d3a
4 changed files with 34 additions and 5 deletions

View file

@ -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