Skip to content

Commit

Permalink
add -v flag on install.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
igtm committed Dec 31, 2022
1 parent 866db00 commit 9041811
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ PullRequest generation tool for Git Flow
sudo curl -sfL https://raw.githubusercontent.com/igtm/create-release-pr/master/install.sh | sudo sh -s -- -b=/usr/local/bin
```

if you want to download old version, pass `-v` argument.

```sh
sudo curl -sfL https://raw.githubusercontent.com/igtm/create-release-pr/master/install.sh | sudo sh -s -- -b=/usr/local/bin -v=v0.0.2
```

# Usage

```
Expand Down
27 changes: 17 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ for i in "$@"; do
executable_folder="${i#*=}"
shift # past argument=value
;;
-v=*)
version="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
Expand All @@ -71,19 +75,22 @@ mkdir -p ${downloadFolder} # make sure download folder exists
os=$(get_os)
arch=$(get_arch)

# latest version: (eg: v1.0.0)
latest_semver=$(
command curl -sSf ${githubUrl}/${owner}/${repo}/releases |
command grep -o -E "/${owner}/${repo}/tree/(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" |
command grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" |
command head -n 1
)
if [[ ! "$latest_semver" ]]; then exit 1; fi
# if not specified
if [[ ! "$version" ]]; then
# latest version: (eg: v1.0.0)
version=$(
command curl -sSf ${githubUrl}/${owner}/${repo}/releases |
command grep -o -E "/${owner}/${repo}/tree/(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" |
command grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" |
command head -n 1
)
if [[ ! "$version" ]]; then exit 1; fi
fi


file_name="${exe_name}_${latest_semver}_${arch}-${os}.tar.gz" # the file name should be download
file_name="${exe_name}_${version}_${arch}-${os}.tar.gz" # the file name should be download
downloaded_file="${downloadFolder}/${file_name}" # the file path should be download
asset_uri="${githubUrl}/${owner}/${repo}/releases/download/${latest_semver}/${file_name}"
asset_uri="${githubUrl}/${owner}/${repo}/releases/download/${version}/${file_name}"

echo "[1/3] Download ${asset_uri} to ${downloadFolder}"
rm -f ${downloaded_file}
Expand Down

0 comments on commit 9041811

Please sign in to comment.