Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rodrigo-lourenco-lopes opened this issue Aug 22, 2024 · 0 comments
Open

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

rodrigo-lourenco-lopes opened this issue Aug 22, 2024 · 0 comments

Comments

@rodrigo-lourenco-lopes
Copy link
Contributor

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.

  • MacOS version of grep does not have the -P flag "grep: invalid option -- 'p'"
  • sed command. On macOS, the -i option requires an argument to specify the extension for a backup file. If you don't want a backup, you need to explicitly provide an empty string (''), but this must be done in a slightly different way than on Linux.

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}'."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant