mirror of
https://codeberg.org/knightsub9/lxcafe.git
synced 2026-07-19 19:30:16 +02:00
62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
question_answered_with_yes() {
|
|
local prompt="$1"
|
|
local ans
|
|
printf '%b\n Enter y or n and press Enter,\n abort with any other key ... [y/N]: ' "$prompt"
|
|
read -r ans
|
|
case "$ans" in
|
|
y|Y) return 0 ;;
|
|
n|N|"") return 1 ;;
|
|
*) echo "Aborted."; exit 1 ;;
|
|
esac
|
|
}
|
|
|
|
echo "Fetching latest from origin..."
|
|
git fetch origin
|
|
git checkout main
|
|
git pull origin main
|
|
|
|
VERSION_FILE="VERSION"
|
|
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '\n')
|
|
|
|
echo "Finalising release of version: $CURRENT_VERSION"
|
|
|
|
RELEASE_BRANCH="release/$CURRENT_VERSION"
|
|
|
|
_local_exists=false
|
|
if git rev-parse "$RELEASE_BRANCH" >/dev/null 2>&1; then
|
|
_local_exists=true
|
|
fi
|
|
|
|
_remote_exists=false
|
|
if git ls-remote --heads origin "$RELEASE_BRANCH" 2>/dev/null | grep -q .; then
|
|
_remote_exists=true
|
|
fi
|
|
|
|
if [ "$_local_exists" = "true" ] || [ "$_remote_exists" = "true" ]; then
|
|
if question_answered_with_yes "Delete release branch $RELEASE_BRANCH (local and remote)?"; then
|
|
[ "$_local_exists" = "true" ] && git branch -D "$RELEASE_BRANCH"
|
|
[ "$_remote_exists" = "true" ] && git push origin --delete "$RELEASE_BRANCH"
|
|
fi
|
|
fi
|
|
|
|
if ! question_answered_with_yes "Create tag $CURRENT_VERSION on main?"; then
|
|
echo "Tag creation aborted."
|
|
exit 0
|
|
fi
|
|
|
|
git tag -a "$CURRENT_VERSION" -m "Release $CURRENT_VERSION"
|
|
|
|
if question_answered_with_yes "Push tag to origin?"; then
|
|
git push origin "$CURRENT_VERSION"
|
|
echo ""
|
|
echo "Tag $CURRENT_VERSION pushed to origin."
|
|
echo "Gitea will create a release from the tag."
|
|
else
|
|
echo "Tag created locally. Push manually with:"
|
|
echo " git push origin $CURRENT_VERSION"
|
|
fi
|