Skip to content

Commit

Permalink
get latest version from GitHub release (#586)
Browse files Browse the repository at this point in the history
* get latest version from GitHub release

* fix uninstall script
  • Loading branch information
coffee-cup authored Jan 8, 2025
1 parent ee981b0 commit 0382d0f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,12 @@ is_build_available() {
UNINSTALL=0
HELP=0

CARGOTOML="$(curl -fsSL https://raw.githubusercontent.com/railwayapp/cli/master/Cargo.toml)"
ALL_VERSIONS="$(sed -n 's/.*version = "\([^"]*\)".*/\1/p' <<EOH
"$CARGOTOML"
EOH
)"
IFS=$'\n' read -r VERSION <<EOH
$ALL_VERSIONS
EOH
DEFAULT_VERSION=$(curl -s https://api.github.com/repos/railwayapp/cli/releases/latest | grep -o '"tag_name": "v.*"' | cut -d'"' -f4 | cut -c2-)

DEFAULT_VERSION="$VERSION"
if [ -z "$DEFAULT_VERSION" ]; then
error "Failed to fetch latest version from GitHub"
exit 1
fi


# defaults
Expand Down Expand Up @@ -466,7 +462,7 @@ if [ "$UNINSTALL" = 1 ]; then

info "$msg"
${sudo} rm "$(which railway)"
${sudo} rm /tmp/railway
${sudo} rm -f /tmp/railway 2>/dev/null || true

info "Removed railway"
exit 0
Expand Down Expand Up @@ -525,4 +521,4 @@ printf "$MAGENTA"
_/j L l\_! _//^---^\\_
EOF
printf "$NO_COLOR"
printf "$NO_COLOR"

0 comments on commit 0382d0f

Please sign in to comment.