From 0fb0f0515a064e2f68e88c614d6166878a5fdd7a Mon Sep 17 00:00:00 2001 From: mboehmlaender Date: Thu, 2 Jul 2026 08:43:06 +0200 Subject: [PATCH] 1.0.0-1 release --- scripts/release.sh | 176 +++++++-------------------------------------- 1 file changed, 27 insertions(+), 149 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index a85f357..65543b4 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -84,42 +84,16 @@ bump_version() { printf '%s.%s.%s' "$major" "$minor" "$patch" } -increment_rc_version() { +increment_build_version() { local version="$1" parse_version "$version" - local rc_number=1 - - if [[ "$PARSED_SUFFIX" =~ ^rc([.]?([0-9]+))?$ ]]; then - if [[ -n "${BASH_REMATCH[2]:-}" ]]; then - rc_number=$((BASH_REMATCH[2] + 1)) - fi - elif [[ -n "$PARSED_SUFFIX" ]]; then - echo "RC-Bump nicht moeglich fuer Suffix '$PARSED_SUFFIX'." - echo "Unterstuetzt: keine Suffixe oder -rc." - exit 1 + local build_number=1 + if [[ -n "$PARSED_BUILD" ]]; then + build_number=$((PARSED_BUILD + 1)) fi - printf '%s.%s.%s-rc%s' "$PARSED_MAJOR" "$PARSED_MINOR" "$PARSED_PATCH" "$rc_number" -} - -can_increment_rc_version() { - local version="$1" - parse_version "$version" - [[ -z "$PARSED_SUFFIX" || "$PARSED_SUFFIX" =~ ^rc([.]?[0-9]+)?$ ]] -} - -remove_rc_suffix() { - local version="$1" - parse_version "$version" - - if [[ ! "$PARSED_SUFFIX" =~ ^rc([.]?[0-9]+)?$ ]]; then - echo "RC-Suffix kann nur von Versionen mit -rc entfernt werden." - echo "Aktuelle Version: $version" - exit 1 - fi - - printf '%s.%s.%s' "$PARSED_MAJOR" "$PARSED_MINOR" "$PARSED_PATCH" + printf '%s.%s.%s-%s' "$PARSED_MAJOR" "$PARSED_MINOR" "$PARSED_PATCH" "$build_number" } select_release_variant() { @@ -206,9 +180,6 @@ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi current_branch="$(git branch --show-current)" -github_release_mode="snapshot" -github_source_branch="" -github_source_ref="" mapfile -t remotes < <(git remote) @@ -240,61 +211,8 @@ if [[ "$selected_remote_url" == *github.com* ]]; then fi echo "Lokaler Branch: $current_branch" - -if [[ "$selected_is_github" == true ]]; then - echo - echo "GitHub-Modus waehlen:" - echo " 1) Snapshot-Release auf Ziel-Branch (bisheriger Ablauf)" - echo " 2) Branch-Merge/Veroeffentlichung dev -> main (force, main uebernimmt dev komplett)" - - default_github_mode="1" - if [[ "$current_branch" == "dev" ]]; then - default_github_mode="2" - fi - - read -r -p "Auswahl [$default_github_mode]: " github_mode_choice - github_mode_choice="${github_mode_choice:-$default_github_mode}" - - case "$github_mode_choice" in - 1) - github_release_mode="snapshot" - ;; - 2) - github_release_mode="branch-force-merge" - ;; - *) - echo "Ungueltige GitHub-Modus-Auswahl." - exit 1 - ;; - esac -fi - -if [[ "$selected_is_github" == true && "$github_release_mode" == "branch-force-merge" ]]; then - echo - read -r -p "Quell-Branch fuer GitHub-Veroeffentlichung [dev]: " github_source_branch - github_source_branch="${github_source_branch:-dev}" - - if ! git check-ref-format --branch "$github_source_branch" >/dev/null 2>&1; then - echo "Ungueltiger Quell-Branch: $github_source_branch" - exit 1 - fi - - if git show-ref --verify --quiet "refs/heads/$github_source_branch"; then - github_source_ref="refs/heads/$github_source_branch" - elif git ls-remote --exit-code --heads "$selected_remote" "$github_source_branch" >/dev/null 2>&1; then - github_source_ref="refs/remotes/$selected_remote/$github_source_branch" - git fetch "$selected_remote" "$github_source_branch" - else - echo "Quell-Branch '$github_source_branch' wurde weder lokal noch auf $selected_remote gefunden." - exit 1 - fi - - read -r -p "Ziel-Branch auf $selected_remote [main]: " target_branch - target_branch="${target_branch:-main}" -else - read -r -p "Ziel-Branch auf $selected_remote [$current_branch]: " target_branch - target_branch="${target_branch:-$current_branch}" -fi +read -r -p "Ziel-Branch auf $selected_remote [$current_branch]: " target_branch +target_branch="${target_branch:-$current_branch}" if ! git check-ref-format --branch "$target_branch" >/dev/null 2>&1; then echo "Ungueltiger Branch-Name: $target_branch" @@ -319,14 +237,7 @@ fi next_patch="$(bump_version "$root_version" patch)" next_minor="$(bump_version "$root_version" minor)" next_major="$(bump_version "$root_version" major)" -next_rc="" -if can_increment_rc_version "$root_version"; then - next_rc="$(increment_rc_version "$root_version")" -fi -current_final="" -if parse_version "$root_version" >/dev/null 2>&1 && [[ "$PARSED_SUFFIX" =~ ^rc([.]?[0-9]+)?$ ]]; then - current_final="$(remove_rc_suffix "$root_version")" -fi +next_build="$(increment_build_version "$root_version")" apply_version_change=false echo "Aktuelle Version: $root_version" @@ -374,43 +285,21 @@ else esac ;; [Nn]) - echo "Option ohne Basisversionssprung waehlen:" - echo " 1) Ohne Versionsaenderung -> $root_version" - if [[ -n "$next_rc" ]]; then - echo " 2) Nur RC-Nummer hochsetzen -> $next_rc" - fi - if [[ -n "$current_final" ]]; then - echo " 3) RC entfernen -> $current_final" - fi + read -r -p "Buildnummer hochsetzen? [y/N]: " should_bump_build + should_bump_build="${should_bump_build:-n}" - read -r -p "Auswahl [1]: " no_bump_choice - no_bump_choice="${no_bump_choice:-1}" - - case "$no_bump_choice" in - 1) + case "$should_bump_build" in + [YyJj]) + target_version="$next_build" + release_mode="Build" + apply_version_change=true + ;; + [Nn]) target_version="$root_version" release_mode="Ohne Versionsaenderung" ;; - 2) - if [[ -z "$next_rc" ]]; then - echo "RC-Bump ist fuer die aktuelle Version nicht verfuegbar." - exit 1 - fi - target_version="$next_rc" - release_mode="RC" - apply_version_change=true - ;; - 3) - if [[ -z "$current_final" ]]; then - echo "RC entfernen ist nur moeglich, wenn die aktuelle Version ein -rc Suffix hat." - exit 1 - fi - target_version="$current_final" - release_mode="RC entfernt" - apply_version_change=true - ;; *) - echo "Ungueltige Auswahl." + echo "Bitte nur Y oder N eingeben." exit 1 ;; esac @@ -428,12 +317,6 @@ echo " Branch: $current_branch -> $selected_remote/$target_branch" echo " Ziel-Ref: $selected_push_ref" echo " Modus: $release_mode" echo " Version: $root_version -> $target_version" -if [[ "$selected_is_github" == true ]]; then - echo " GitHub: $github_release_mode" - if [[ "$github_release_mode" == "branch-force-merge" ]]; then - echo " Quelle: $github_source_branch -> $target_branch (force)" - fi -fi confirm_or_exit "Fortfahren? [Y/n]: " echo @@ -471,27 +354,22 @@ echo "Push vorbereiten..." if [[ "$selected_is_github" == true ]]; then - if [[ "$github_release_mode" == "branch-force-merge" ]]; then - echo "GitHub erkannt: $github_source_branch wird mit Force nach $target_branch uebernommen." - git push "$selected_remote" "$github_source_ref:$selected_push_ref" --force - else - echo "GitHub erkannt: Squash-Commit wird erzeugt." + echo "GitHub erkannt: Squash-Commit wird erzeugt." - temp_branch="github-publish-$target_branch" + temp_branch="github-publish-$target_branch" - git checkout -B "$temp_branch" + git checkout -B "$temp_branch" - first_commit="$(git rev-list --max-parents=0 HEAD)" + first_commit="$(git rev-list --max-parents=0 HEAD)" - git reset --soft "$first_commit" + git reset --soft "$first_commit" - git commit -m "$target_version release snapshot" + git commit -m "$target_version release snapshot" - git push "$selected_remote" "$temp_branch:$selected_push_ref" --force + git push "$selected_remote" "$temp_branch:$selected_push_ref" --force - git checkout "$current_branch" - git branch -D "$temp_branch" - fi + git checkout "$current_branch" + git branch -D "$temp_branch" else