@@ -50,47 +50,6 @@ find_version_from_git_tags() {
5050 echo " ${variable_name} =${! variable_name} "
5151}
5252
53- # Use semver logic to decrement a version number then look for the closest match
54- find_prev_version_from_git_tags () {
55- local variable_name=$1
56- local current_version=${! variable_name}
57- local repository=$2
58- # Normally a "v" is used before the version number, but support alternate cases
59- local prefix=${3:- " tags/v" }
60- # Some repositories use "_" instead of "." for version number part separation, support that
61- local separator=${4:- " ." }
62- # Some tools release versions that omit the last digit (e.g. go)
63- local last_part_optional=${5:- " false" }
64- # Some repositories may have tags that include a suffix (e.g. actions/node-versions)
65- local version_suffix_regex=$6
66- # Try one break fix version number less if we get a failure. Use "set +e" since "set -e" can cause failures in valid scenarios.
67- set +e
68- major=" $( echo " ${current_version} " | grep -oE ' ^[0-9]+' || echo ' ' ) "
69- minor=" $( echo " ${current_version} " | grep -oP ' ^[0-9]+\.\K[0-9]+' || echo ' ' ) "
70- breakfix=" $( echo " ${current_version} " | grep -oP ' ^[0-9]+\.[0-9]+\.\K[0-9]+' 2> /dev/null || echo ' ' ) "
71-
72- if [ " ${minor} " = " 0" ] && [ " ${breakfix} " = " 0" ]; then
73- (( major= major- 1 ))
74- declare -g ${variable_name} =" ${major} "
75- # Look for latest version from previous major release
76- find_version_from_git_tags " ${variable_name} " " ${repository} " " ${prefix} " " ${separator} " " ${last_part_optional} "
77- # Handle situations like Go's odd version pattern where "0" releases omit the last part
78- elif [ " ${breakfix} " = " " ] || [ " ${breakfix} " = " 0" ]; then
79- (( minor= minor- 1 ))
80- declare -g ${variable_name} =" ${major} .${minor} "
81- # Look for latest version from previous minor release
82- find_version_from_git_tags " ${variable_name} " " ${repository} " " ${prefix} " " ${separator} " " ${last_part_optional} "
83- else
84- (( breakfix= breakfix- 1 ))
85- if [ " ${breakfix} " = " 0" ] && [ " ${last_part_optional} " = " true" ]; then
86- declare -g ${variable_name} =" ${major} .${minor} "
87- else
88- declare -g ${variable_name} =" ${major} .${minor} .${breakfix} "
89- fi
90- fi
91- set -e
92- }
93-
9453install_using_github () {
9554 check_packages wget
9655 arch=$( dpkg --print-architecture)
@@ -104,10 +63,9 @@ install_using_github() {
10463 exit_code=$?
10564 set -e
10665 if [ " $exit_code " != " 0" ]; then
107- # Handle situation where git tags are ahead of what was is available to actually download
108- echo " (!) copilot-cli version ${CLI_VERSION} failed to download. Attempting to fall back one version to retry..."
109- find_prev_version_from_git_tags CLI_VERSION https://github.com/github/copilot-cli
110- wget -q --show-progress --progress=dot:giga https://github.com/github/copilot-cli/releases/download/v${CLI_VERSION} /${cli_filename}
66+ # Fallback to latest version if the specified version does not exist
67+ echo " (!) copilot-cli version ${CLI_VERSION} failed to download. Attempting to fall back to latest version..."
68+ wget -q --show-progress --progress=dot:giga https://github.com/github/copilot-cli/releases/latest/download/${cli_filename}
11169 fi
11270
11371 tar -xzf /tmp/copilotcli/${cli_filename}
0 commit comments