mirror of
https://codeberg.org/knightsub9/lxcafe.git
synced 2026-07-19 19:30:16 +02:00
86 lines
2.3 KiB
Bash
Executable File
86 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "Error: You have uncommitted local changes."
|
|
echo "Please commit or stash them before releasing."
|
|
echo ""
|
|
echo "Uncommitted files:"
|
|
git status --short
|
|
exit 1
|
|
fi
|
|
|
|
VERSION_FILE="VERSION"
|
|
SCRIPT_FILE="post_installation_script/Nachinstallationsarbeiten_LC_Esslingen_XFCE.sh"
|
|
|
|
if [ ! -f "$VERSION_FILE" ]; then
|
|
echo "Error: $VERSION_FILE not found"
|
|
exit 1
|
|
fi
|
|
|
|
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '\n')
|
|
|
|
if [ ! -f "$SCRIPT_FILE" ]; then
|
|
echo "Error: $SCRIPT_FILE not found"
|
|
exit 1
|
|
fi
|
|
|
|
CURRENT_MAJOR=${CURRENT_VERSION#v}
|
|
|
|
if ! [[ "$CURRENT_VERSION" =~ ^v[0-9]+$ ]]; then
|
|
echo "Error: Invalid version format in $VERSION_FILE. Expected v0, v1, v2, etc."
|
|
exit 1
|
|
fi
|
|
|
|
NEXT_VERSION=$((CURRENT_MAJOR + 1))
|
|
NEXT_VERSION_STR="v$NEXT_VERSION"
|
|
|
|
if git rev-parse "refs/tags/$NEXT_VERSION_STR" >/dev/null 2>&1; then
|
|
echo "Error: Tag $NEXT_VERSION_STR already exists locally."
|
|
exit 1
|
|
fi
|
|
|
|
if git remote get-url origin >/dev/null 2>&1; then
|
|
if git ls-remote --tags origin "$NEXT_VERSION_STR" 2>/dev/null | grep -q "$NEXT_VERSION_STR"; then
|
|
echo "Error: Tag $NEXT_VERSION_STR already exists on remote."
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Warning: No remote configured. You can still create the release locally."
|
|
fi
|
|
|
|
echo "Current version: $CURRENT_VERSION"
|
|
echo "Proposed version: $NEXT_VERSION_STR"
|
|
echo ""
|
|
|
|
read -p "Confirm release version $NEXT_VERSION_STR? [y/N]: " confirm
|
|
|
|
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
|
|
echo "Release aborted."
|
|
exit 0
|
|
fi
|
|
|
|
echo "$NEXT_VERSION_STR" > "$VERSION_FILE"
|
|
|
|
sed -i.bak "s/^SCRIPT_VERSION=.*/SCRIPT_VERSION=\"$NEXT_VERSION_STR\"/" "$SCRIPT_FILE"
|
|
if [ -f "${SCRIPT_FILE}.bak" ]; then
|
|
rm "${SCRIPT_FILE}.bak"
|
|
fi
|
|
|
|
git add "$VERSION_FILE" "$SCRIPT_FILE"
|
|
git commit -m "Release $NEXT_VERSION_STR"
|
|
|
|
git tag -a "$NEXT_VERSION_STR" -m "Release $NEXT_VERSION_STR"
|
|
|
|
echo ""
|
|
echo "Tag $NEXT_VERSION_STR created locally."
|
|
read -p "Push to origin (includes tags)? [y/N]: " push_confirm
|
|
|
|
if [[ "$push_confirm" == "y" || "$push_confirm" == "Y" ]]; then
|
|
git push origin --tags
|
|
echo "Done! Gitea will create release from tag $NEXT_VERSION_STR"
|
|
else
|
|
echo "Release prepared locally. Push manually with: git push origin --tags"
|
|
fi
|