diff --git a/scripts/dev-tools/dev-tools b/scripts/dev-tools/dev-tools index 5f9ba9c..26c62ba 100755 --- a/scripts/dev-tools/dev-tools +++ b/scripts/dev-tools/dev-tools @@ -54,6 +54,7 @@ dev_tools_usage() { printf " %s pull latest image of bashly\n" "cli-generate-pull " printf " %s print out help about bashly\n" "cli-generate-help " printf " %s set the version for rcstack\n" "stack-cli-version " + printf " %s set the version for rcstack docker image\n" "stack-image-version" printf " %s run a ./rcstack generation script\n" "cli-generate-rc " printf " %s run a ./dev-tools generation script\n" "cli-generate-dev " echo @@ -700,6 +701,43 @@ dev_tools_stack_cli_version_usage() { } # :command.usage +dev_tools_stack_image_version_usage() { + if [[ -n $long_usage ]]; then + printf "dev-tools stack-image-version - set the version for rcstack docker image\n" + echo + + else + printf "dev-tools stack-image-version - set the version for rcstack docker image\n" + echo + + fi + + printf "%s\n" "Usage:" + printf " dev-tools stack-image-version VERSION\n" + printf " dev-tools stack-image-version --help | -h\n" + echo + + # :command.long_usage + if [[ -n $long_usage ]]; then + printf "%s\n" "Options:" + + # :command.usage_fixed_flags + printf " %s\n" "--help, -h" + printf " Show this help\n" + echo + + # :command.usage_args + printf "%s\n" "Arguments:" + + # :argument.usage + printf " %s\n" "VERSION" + printf " Version to set e.g '5.0.0'\n" + echo + + fi +} + +# :command.usage dev_tools_cli_generate_rc_usage() { if [[ -n $long_usage ]]; then printf "dev-tools cli-generate-rc - run a ./rcstack generation script\n" @@ -1634,6 +1672,25 @@ dev_tools_stack_cli_version_command() { } # :command.function +dev_tools_stack_image_version_command() { + # src/stack_image_version_command.sh + version=${args[version]} + + #ARG RHODECODE_VERSION=5.0.0 + docker_file=$(pwd)/service/rhodecode/rhodecode_5.dockerfile + + # rc_image_ver=5.0.0 + initialize_file=$(pwd)/scripts/rcstack/src/initialize.sh + + echo "Setting $version to $docker_file" + sed -i -E "s/ARG RHODECODE_VERSION.+/ARG RHODECODE_VERSION=$version/" $docker_file + + echo "Setting $version to $initialize_file" + sed -i -E "s/rc_image_ver.+/rc_image_ver=$version/" $initialize_file + +} + +# :command.function dev_tools_cli_generate_rc_command() { # src/cli_generate_rc_command.sh one_time=${args[--one-time]} @@ -2001,6 +2058,13 @@ parse_requirements() { shift $# ;; + stack-image-version) + action="stack-image-version" + shift + dev_tools_stack_image_version_parse_requirements "$@" + shift $# + ;; + cli-generate-rc) action="cli-generate-rc" shift @@ -3117,6 +3181,62 @@ dev_tools_stack_cli_version_parse_requirements() { } # :command.parse_requirements +dev_tools_stack_image_version_parse_requirements() { + # :command.fixed_flags_filter + while [[ $# -gt 0 ]]; do + case "${1:-}" in + --help | -h) + long_usage=yes + dev_tools_stack_image_version_usage + exit + ;; + + *) + break + ;; + + esac + done + + # :command.command_filter + action="stack-image-version" + + # :command.parse_requirements_while + while [[ $# -gt 0 ]]; do + key="$1" + case "$key" in + + -?*) + printf "invalid option: %s\n" "$key" >&2 + exit 1 + ;; + + *) + # :command.parse_requirements_case + # :command.parse_requirements_case_simple + if [[ -z ${args['version']+x} ]]; then + + args['version']=$1 + shift + else + printf "invalid argument: %s\n" "$key" >&2 + exit 1 + fi + + ;; + + esac + done + + # :command.required_args_filter + if [[ -z ${args['version']+x} ]]; then + printf "missing required argument: VERSION\nusage: dev-tools stack-image-version VERSION\n" >&2 + exit 1 + fi + +} + +# :command.parse_requirements dev_tools_cli_generate_rc_parse_requirements() { # :command.fixed_flags_filter while [[ $# -gt 0 ]]; do @@ -3644,6 +3764,7 @@ run() { "cli-generate-pull") dev_tools_cli_generate_pull_command ;; "cli-generate-help") dev_tools_cli_generate_help_command ;; "stack-cli-version") dev_tools_stack_cli_version_command ;; + "stack-image-version") dev_tools_stack_image_version_command ;; "cli-generate-rc") dev_tools_cli_generate_rc_command ;; "cli-generate-dev") dev_tools_cli_generate_dev_command ;; "get-build-artifacts") dev_tools_get_build_artifacts_command ;;