This is an automated email from the ASF dual-hosted git repository.

MartijnVisser pushed a commit to branch release_utils
in repository 
https://gitbox.apache.org/repos/asf/flink-connector-shared-utils.git


The following commit(s) were added to refs/heads/release_utils by this push:
     new 802627b  [FLINK-41154] Make release_utils work on macOS and Linux (#62)
802627b is described below

commit 802627b59d143e8c43181b23b4b56d89d418ed60
Author: Martijn Visser <[email protected]>
AuthorDate: Mon Oct 26 13:32:03 2026 +0100

    [FLINK-41154] Make release_utils work on macOS and Linux (#62)
    
    - Stop exporting SHELLOPTS, which broke bin/mvn on macOS, and drop the
      set +u guards and README Maven variables that worked around it
    - Make the MVN override work and use it in release_snapshot_branch.sh
    - Fix the default project name in stage_source_release.sh
    - Commit only the poms in update_branch_version.sh
    - Keep macOS ._* files out of the source tarball
    - Stop when Maven cannot read the project version or reports an
      unexpected flink.version
    - Use portable sed -i in update_japicmp_configuration.sh
    
    Generated-by: Claude Code (Claude Opus 5.5)
---
 README.md                       |  4 ----
 _init.sh                        |  4 +---
 _utils.sh                       | 34 ++++++++++++++++++++++++----------
 release_snapshot_branch.sh      |  7 +++----
 stage_jars.sh                   |  3 ++-
 stage_source_release.sh         | 11 ++++++++---
 update_branch_version.sh        |  2 +-
 update_japicmp_configuration.sh |  3 ++-
 8 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md
index 198bddc..b4694ad 100644
--- a/README.md
+++ b/README.md
@@ -14,10 +14,6 @@ export TARGET_JAVA_VERSION=8
 export RC_NUM=1
 export PROJECT=flink-connector-<project>
 export REMOTE=origin
-export MAVEN_SKIP_RC=false
-export MAVEN_OPTS=""
-export MAVEN_CONFIG=""
-export MAVEN_DEBUG_OPTS=""
 ```
 These are checked at the start of each script.  
 Any instance of `${some_variable}` in this document refers to an environment 
variable that is used by the respective
diff --git a/_init.sh b/_init.sh
index 060d709..4aa1c0a 100644
--- a/_init.sh
+++ b/_init.sh
@@ -24,8 +24,6 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
-export SHELLOPTS
-
 ###########################
 
 TARGET_JAVA_VERSION=${TARGET_JAVA_VERSION:-8}
@@ -47,7 +45,7 @@ ARTIFACTS_DIR=${SOURCE_DIR}/tools/releasing/release/artifacts
 SVN_DEV_DIR="https://dist.apache.org/repos/dist/dev/flink";
 SVN_RELEASE_DIR="https://dist.apache.org/repos/dist/release/flink";
 
-if [ -n "MVN" ]; then
+if [ -z "${MVN:-}" ]; then
   if [ -e "${SOURCE_DIR}/mvnw" ]; then
     MVN=${SOURCE_DIR}/mvnw
   else
diff --git a/_utils.sh b/_utils.sh
index 8cbe559..b85470b 100644
--- a/_utils.sh
+++ b/_utils.sh
@@ -59,9 +59,17 @@ function create_pristine_source {
 }
 
 function get_pom_version {
-  set +u
-  echo $(${MVN} help:evaluate -Dexpression="project.version" -q -DforceStdout)
-  set -u
+  local version
+  local version_pattern='^[0-9]+(\.[0-9]+)*(-[0-9A-Za-z.]+)*$'
+  version=$(${MVN} help:evaluate -Dexpression="project.version" -q 
-DforceStdout) || {
+    echo "Maven failed to read the project version." >&2
+    exit 1
+  }
+  if [[ ! ${version} =~ ${version_pattern} ]]; then
+    echo "Unexpected project version '${version}'." >&2
+    exit 1
+  fi
+  echo "${version}"
 }
 
 function set_pom_version {
@@ -71,12 +79,18 @@ function set_pom_version {
 }
 
 function is_flink_version_set_in_pom {
-  set +u
-  version=$(${MVN} help:evaluate -Dexpression="flink.version" -q -DforceStdout)
-  if [[ "${version}" =~ ^[0-9\.\-]+$ ]]; then
-      echo "true"
-    else
-      echo "false"
+  local version
+  local version_pattern='^[0-9]+(\.[0-9]+)*(-[0-9A-Za-z.]+)*$'
+  version=$(${MVN} help:evaluate -Dexpression="flink.version" -q 
-DforceStdout) || {
+    echo "Maven failed to read flink.version." >&2
+    exit 1
+  }
+  if [[ ${version} =~ ${version_pattern} ]]; then
+    echo "true"
+  elif [[ -z ${version} || ${version} == "null object or invalid expression" 
]]; then
+    echo "false"
+  else
+    echo "Unexpected flink.version '${version}'." >&2
+    exit 1
   fi
-  set -u
 }
\ No newline at end of file
diff --git a/release_snapshot_branch.sh b/release_snapshot_branch.sh
index 202773f..a5da82d 100755
--- a/release_snapshot_branch.sh
+++ b/release_snapshot_branch.sh
@@ -20,16 +20,15 @@
 SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
 
 source "${SCRIPT_DIR}/_init.sh"
+source "${SCRIPT_DIR}/_utils.sh"
 
 ###########################
 
 function create_snapshot_branch {
   cd "${SOURCE_DIR}"
 
-  set +u
-  version=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout 
| sed "s/-SNAPSHOT//")
-  set -u
-  branch="v${version}"
+  version=$(get_pom_version)
+  branch="v${version%-SNAPSHOT}"
 
   git checkout -b ${branch}
   git push ${REMOTE} ${branch}:${branch}
diff --git a/stage_jars.sh b/stage_jars.sh
index 6953a39..6a5981f 100755
--- a/stage_jars.sh
+++ b/stage_jars.sh
@@ -34,7 +34,8 @@ function deploy_staging_jars {
     exit 1
   fi
 
-  if [ "$(is_flink_version_set_in_pom)" == "true" ]; then # it is a regular 
connector release
+  flink_version_set=$(is_flink_version_set_in_pom)
+  if [ "${flink_version_set}" == "true" ]; then # it is a regular connector 
release
     check_variables_set FLINK_VERSION
     flink_minor_version=${FLINK_MINOR_VERSION:-$(echo ${FLINK_VERSION} | cut 
-d. -f1,2)}
     version="${project_version}-${flink_minor_version}"
diff --git a/stage_source_release.sh b/stage_source_release.sh
index e84d4fc..4c3d614 100755
--- a/stage_source_release.sh
+++ b/stage_source_release.sh
@@ -33,7 +33,7 @@ function create_source_release {
   mkdir -p ${RELEASE_DIR}
   mkdir -p ${ARTIFACTS_DIR}
 
-  project=${PROJECT:-PWD##*/}
+  project=${PROJECT:-${PWD##*/}}
   version=$(get_pom_version)
   if [[ ${version} =~ -SNAPSHOT$ ]]; then
     echo "Source releases should not be created for SNAPSHOT versions. Use 
'update_branch_version.sh' first."
@@ -48,7 +48,12 @@ function create_source_release {
   mv ${clone_dir} ${versioned_dir}
 
   cd "${ARTIFACTS_DIR}"
-  tar czf ${ARTIFACTS_DIR}/${project}-${version}-src.tgz ${versioned_dir##*/}
+  # macOS's bsdtar otherwise adds AppleDouble ._* files and extended 
attributes; busybox tar has no --no-xattrs
+  tar_options=""
+  case "$(tar --version 2>/dev/null)" in
+    *bsdtar*) tar_options="--no-xattrs" ;;
+  esac
+  COPYFILE_DISABLE=1 tar ${tar_options} -czf 
${ARTIFACTS_DIR}/${project}-${version}-src.tgz ${versioned_dir##*/}
   gpg --armor --detach-sig ${ARTIFACTS_DIR}/${project}-${version}-src.tgz
   ${SHASUM} ${project}-${version}-src.tgz >${project}-${version}-src.tgz.sha512
 
@@ -57,7 +62,7 @@ function create_source_release {
 
 function deploy_source_release {
   cd ${SOURCE_DIR}
-  project=${PROJECT:-PWD##*/}
+  project=${PROJECT:-${PWD##*/}}
   version=$(get_pom_version)-rc${RC_NUM}
 
   release=${project}-${version}
diff --git a/update_branch_version.sh b/update_branch_version.sh
index 0c43b57..97d272a 100755
--- a/update_branch_version.sh
+++ b/update_branch_version.sh
@@ -33,7 +33,7 @@ function update_branch_version {
 
   set_pom_version "${NEW_VERSION}"
 
-  git commit -am "Update version to $NEW_VERSION"
+  git commit -m "Update version to ${NEW_VERSION}" -- ':(glob)**/pom.xml'
 
   echo "Done."
 }
diff --git a/update_japicmp_configuration.sh b/update_japicmp_configuration.sh
index ce3784f..4b76648 100755
--- a/update_japicmp_configuration.sh
+++ b/update_japicmp_configuration.sh
@@ -70,7 +70,8 @@ function clear_exclusions() {
   exclusion_end=$(($(sed -n '/<!-- MARKER: end exclusions/=' pom.xml) - 1))
 
   if [[ $exclusion_start -lt $exclusion_end ]]; then
-    sed -i "${exclusion_start},${exclusion_end}d" pom.xml
+    sed -i.bak "${exclusion_start},${exclusion_end}d" pom.xml
+    rm -f pom.xml.bak
   fi
 }
 

Reply via email to