zeebe-io / benchmark-helm

Contains a helm chart to execute zeebe benchmarks
https://zeebe-io.github.io/benchmark-helm/
Apache License 2.0
2 stars 0 forks source link

"make release.chores" does not work on MasOS #181

Open rodrigo-lourenco-lopes opened 3 weeks ago

rodrigo-lourenco-lopes commented 3 weeks ago

The scrip in release chores, does not work out of the box in MacOS due to the differences in some of the commands used in both operating systems namely with the commands grep and sed.

Due to the sporadic use of the scrip might not be necessary to change the scrip to be compatible with both operating systems, but would be nice to have the problem documented, and the work-around.

The easiest solution is to install GNU grep with brew install grep and use the command ggrep, and for the sed command just adding '' after the -i flag, therefore the file bump-chart-version.sh should be replaced with the following:

#!/bin/bash
set -euo pipefail

print_help () {
cat << EOF
Usage:
    $0 [chart-name]

Details:
    A simple script to bump the chart version.
    Updating the Chart.yaml version will trigger Helm release with the new version.

Notes:
    Default value for 'chart-name' is 'camunda-platform'.
EOF
}

if [ "${1:-''}" == '-h' ]; then
  print_help
  exit 1
fi

# Chart name is hard-coded since we only have 1 main chart,
# but it could be customized in case we have more in the future.
chart_name="zeebe-benchmark"

# When changing the minor version, export "is_minor_version=1",
# that will increment the minor version and set the patch version to zero.
is_minor_version="${is_minor_version:-0}"

# Generate new version based on the old one.
chart_version_old=$(ggrep -Po "(?<=^version: ).+" charts/${chart_name}/Chart.yaml)
chart_version_new=$(echo "${chart_version_old}" |
    awk -F '.' -v OFS='.' -v is_minor_version=${is_minor_version} \
      '{
        if (is_minor_version) {
          printf "%d.%d.0", $1, $2+1, $3
        } else {
          $NF += 1; print;
        }
      }'
)

# Update the appVersion in parent chart in case it's a minor release.
if [[ ${is_minor_version} -eq 1 ]]; then
    chart_version_new_minor=$(echo "${chart_version_new%.0}.x")
    sed -i '' "s/^appVersion: 8.*/appVersion: ${chart_version_new_minor}/g" charts/${chart_name}/Chart.yaml
fi

# Update parent chart version
sed -i '' "s/version: ${chart_version_old}/version: ${chart_version_new}/g" charts/${chart_name}/Chart.yaml

# Print the changes.
echo "The chart '${chart_name}' version has been bumped from '${chart_version_old}' to '${chart_version_new}'."