Skip to content

Commit

Permalink
Update versions scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizlab committed Dec 6, 2020
1 parent a194920 commit ca21a5c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Scripts/bump_locmapper_build_number.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Scripts/set_locmapper_marketing_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file removed Scripts/zz_bin/hagvtool
Binary file not shown.
10 changes: 0 additions & 10 deletions Scripts/zz_lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
30 changes: 15 additions & 15 deletions Scripts/zz_lib/set_project_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=()
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit ca21a5c

Please sign in to comment.