pingtimeout commented on code in PR #2156:
URL: https://github.com/apache/polaris/pull/2156#discussion_r2225971293


##########
releasey/02-create-release-branch.sh:
##########
@@ -0,0 +1,186 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# Create Release Branch Script
+#
+# Automates the "Create release branch" section of the release guide.
+# Creates a new release branch and sets the target release version.
+#
+
+set -euo pipefail
+
+releases_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+libs_dir="${releases_dir}/libs"
+
+source "${libs_dir}/_log.sh"
+source "${libs_dir}/_constants.sh"
+source "${libs_dir}/_exec.sh"
+source "${libs_dir}/_files.sh"
+
+function usage() {
+  cat << EOF
+$(basename "$0") --version VERSION [--commit GIT_COMMIT] [--recreate] [--help 
| -h]
+
+  Creates a release branch and sets the target release version.
+
+  Options:
+    --version VERSION
+        The release version in format x.y.z-incubating
+    --commit GIT_COMMIT
+        The Git commit SHA to create the release branch from. Defaults to 
current HEAD.
+    --recreate
+        Drop the release branch if it already exists and recreate it to the 
new SHA.
+    -h --help
+        Print usage information.
+
+  Examples:
+    $(basename "$0") --version 1.0.0-incubating --commit HEAD
+    $(basename "$0") --version 0.1.0-incubating --commit abc123def456
+    $(basename "$0") --version 1.0.0-incubating --commit HEAD --recreate
+
+EOF
+}
+
+ensure_cwd_is_project_root
+
+version=""
+commit="HEAD"
+recreate=false
+
+while [[ $# -gt 0 ]]; do
+  case $1 in
+    --version)
+      if [[ $# -lt 2 ]]; then
+        print_error "Missing argument for --version"
+        usage >&2
+        exit 1
+      fi
+      version="$2"
+      shift 2
+      ;;
+    --commit)
+      if [[ $# -lt 2 ]]; then
+        print_error "Missing argument for --commit"
+        usage >&2
+        exit 1
+      fi
+      commit="$2"
+      shift 2
+      ;;
+    --recreate)
+      recreate=true
+      shift
+      ;;
+    --help|-h)
+      usage
+      exit 0
+      ;;
+    *)
+      print_error "Unknown option/argument $1"
+      usage >&2
+      exit 1
+      ;;
+  esac
+done
+
+# Ensure the version is provided
+if [[ -z ${version} ]]; then
+  print_error "Missing version"
+  usage >&2
+  exit 1
+fi
+
+# Validate that the commit exists
+if ! git rev-parse --verify "${commit}" >/dev/null 2>&1; then
+  print_error "Invalid Git commit: ${commit}"
+  usage >&2
+  exit 1
+fi
+
+# Validate version format: x.y.z-incubating
+# TODO: Remove incubating when we are a TLP
+version_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)-incubating$"
+if [[ ! ${version} =~ ${version_regex} ]]; then

Review Comment:
   This is actually correct (and intended).  Let me explain.  The goal is to 
make it clear that a release branch should only be created for an `x.y.z` 
version.  So the release branch script should only be called with a version 
that does not include rc.
   
   That being said, now I am having second thoughts.  If we trigger releases 
via GH workflows, this script will always be invoked, right?  We won't have a 
workflow for "cut RC1" and another workflow for "cut another RC".  So maybe I 
should update this script to enable that and only create the release branch if 
this is about RC1...  Let me see what I can come up with.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to