diff --git a/Scripts/bump_locmapper_build_number.sh b/Scripts/bump_locmapper_build_number.sh index 5e6fdd5..71df631 100755 --- a/Scripts/bump_locmapper_build_number.sh +++ b/Scripts/bump_locmapper_build_number.sh @@ -16,9 +16,9 @@ if [ -n "$1" -o "$1" = "--help" ]; then exit 1 fi -"$lib_dir/set_project_version.sh" --targets "LocMapper,LocMapperTests,LocMapper CLI,LocMapper App" --bump-build-version --commit +"$lib_dir/set_project_version.sh" --targets "LocMapper" --targets "LocMapperTests" --targets "LocMapper CLI" --targets "LocMapper App" --bump-build-version --commit || exit 3 # Change hard-coded version in LocMapper CLI -version="$("$bin_dir/hagvtool" --porcelain print-build-number 2>/dev/null | grep 'LocMapper CLI' | tail -n1 | cut -d':' -f2)" +version="$(hagvtool --output-format json --targets "LocMapper CLI" get-versions | jq -r .reduced_build_version_for_all)" || exit 3 sed -i '' -E 's|^.*__VERSION_LINE_TOKEN__.*$| static var version = "'"$version"'" /* Do not remove this token, it is used by a script: __VERSION_LINE_TOKEN__ */|' "./LocMapper CLI/main.swift" git commit -a --amend --no-edit diff --git a/Scripts/set_locmapper_marketing_version.sh b/Scripts/set_locmapper_marketing_version.sh index fd486e5..6d27e75 100755 --- a/Scripts/set_locmapper_marketing_version.sh +++ b/Scripts/set_locmapper_marketing_version.sh @@ -17,4 +17,4 @@ if [ -z "$version" -o "$version" = "--help" ]; then exit 1 fi -"$lib_dir/set_project_version.sh" --targets "LocMapperTests,LocMapper App" --set-marketing-version "$version" --commit +"$lib_dir/set_project_version.sh" --targets "LocMapper" --targets "LocMapperTests" --targets "LocMapper CLI" --targets "LocMapper App" --set-marketing-version "$version" --commit diff --git a/Scripts/zz_bin/hagvtool b/Scripts/zz_bin/hagvtool deleted file mode 100755 index bbecf54..0000000 Binary files a/Scripts/zz_bin/hagvtool and /dev/null differ diff --git a/Scripts/zz_lib/common.sh b/Scripts/zz_lib/common.sh index 740dab0..32ae7ef 100644 --- a/Scripts/zz_lib/common.sh +++ b/Scripts/zz_lib/common.sh @@ -50,13 +50,3 @@ print_warning_message_read_response() { read -p "$* $COLOR_ACTION" $var_name printf "$COLOR_CLEAR" } - - -# hagvtool utility: Parses the output expecting exactly ONE version from a -# porcelain output -parse_hagvtool_output() { - last_line="$(echo "$1" | tail -n 1)" - first_char=${last_line:0:1} - if [ "$first_char" != ":" ]; then exit 1; fi - echo ${last_line:1} -} diff --git a/Scripts/zz_lib/set_project_version.sh b/Scripts/zz_lib/set_project_version.sh index 3ea353b..538fea8 100755 --- a/Scripts/zz_lib/set_project_version.sh +++ b/Scripts/zz_lib/set_project_version.sh @@ -8,18 +8,18 @@ source "$lib_dir/common.sh" || exit 255 ########################################## -# Instead of using agvtool, we'll be coding our own version of agvtool -# Why? Because agvtool does not support target-based version setting... - - usage() { - echo "syntax: $0 [--project path_to_xcodeproj] [--targets target1,target2,...] [--bump-build-version|--set-build-version new_version] [--set-marketing-version new_marketing_version] ([--force] [--commit]|[--no-commit])" >/dev/stderr - echo " exits with status 1 for syntax error, 2 if repo is dirty and force is not set, 3 on hagvtool error, 4 on commit error after hagvtool updated the version of the project" >/dev/stderr + echo "syntax: $0 [--project path_to_xcodeproj] [--targets target1 --targets target2 ...] [--bump-build-version|--set-build-version new_version] [--set-marketing-version new_marketing_version] ([--force] [--commit]|[--no-commit])" >/dev/stderr + echo " exits with status 1 for syntax error, 2 if repo is dirty and force is not set, 3 on hagvtool error, 4 on commit error after hagvtool updated the version of the project, 5 if a dep is not found" >/dev/stderr echo " note: --help makes program exit with status 1 too" >/dev/stderr exit 1 } +command -v jq >/dev/null 2>&1 || { echo "Please install jq (e.g. brew install jq) to use this script" >/dev/stderr; exit 5; } +command -v hagvtool >/dev/null 2>&1 || { echo "Please install hagvtool (e.g. brew install happn-tech/public/hagvtool) to use this script" >/dev/stderr; exit 5; } + + force=0 commit=-1 hagvtool_options=() @@ -31,7 +31,7 @@ while [ -n "$1" ]; do --project) shift [ -n "$1" ] || usage - hagvtool_options=("${hagvtool_options[@]}" "--project-path=$1") + hagvtool_options=("${hagvtool_options[@]}" "--path-to-xcodeproj=$1") ;; --targets) shift @@ -82,20 +82,20 @@ test "$force" = "1" || "$lib_dir/is_repo_clean.sh" || exit 1 case "$new_build_version" in "BUMP") - output="$("$bin_dir/hagvtool" "${hagvtool_options[@]}" --porcelain bump-build-number)" || exit 3 - version="$(parse_hagvtool_output "$output")" || exit 3 + current_build_number="$(hagvtool "${hagvtool_options[@]}" --output-format json get-versions | jq -r .reduced_build_version_for_all)" || exit 3 + test "$current_build_number" != "null" || { echo "Cannot get current build number" >/dev/stderr; exit 3; } + version="$((current_build_number + 1))" || exit 3 + hagvtool "${hagvtool_options[@]}" set-build-version "$version" || exit 3 test "$commit" = "1" && ( "$lib_dir/is_repo_clean.sh" || git commit -am "Bump build number to \"$version\" with hagvtool" ) || exit 4 ;; *) if [ -n "$new_build_version" ]; then - output="$("$bin_dir/hagvtool" "${hagvtool_options[@]}" --porcelain set-build-number "$new_build_version")" || exit 3 - version="$(parse_hagvtool_output "$output")" || exit 3 - test "$commit" = "1" && ( "$lib_dir/is_repo_clean.sh" || git commit -am "Set build number to \"$version\" with hagvtool" ) || exit 4 + hagvtool "${hagvtool_options[@]}" set-build-version "$new_build_version" || exit 3 + test "$commit" = "1" && ( "$lib_dir/is_repo_clean.sh" || git commit -am "Set build number to \"$new_build_version\" with hagvtool" ) || exit 4 fi ;; esac if [ -n "$new_marketing_version" ]; then - output="$("$bin_dir/hagvtool" "${hagvtool_options[@]}" --porcelain set-marketing-version "$new_marketing_version")" || exit 3 - version="$(parse_hagvtool_output "$output")" || exit 3 - test "$commit" = "1" && ( "$lib_dir/is_repo_clean.sh" || git commit -am "Set marketing version to \"$version\" with hagvtool" ) || exit 4 + hagvtool "${hagvtool_options[@]}" set-marketing-version "$new_marketing_version" || exit 3 + test "$commit" = "1" && ( "$lib_dir/is_repo_clean.sh" || git commit -am "Set marketing version to \"$new_marketing_version\" with hagvtool" ) || exit 4 fi