Skip to content

Commit

Permalink
Add upgrade commands
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Dec 19, 2024
1 parent 5c03e13 commit 352b7e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- uses: actions/checkout@v4
- run: ./wshandler install_test_deps
- run: sudo ./wshandler --policy download install /usr/bin/
- run: sudo ./wshandler upgrade /usr/bin/
- run: make test WSHANDLER=wshandler

ubuntu22-snap-yq:
Expand All @@ -34,6 +35,7 @@ jobs:
- uses: actions/checkout@v4
- run: ./wshandler install_test_deps
- run: sudo ./wshandler --policy snap install /usr/bin/
- run: sudo ./wshandler upgrade /usr/bin/
- run: make test WSHANDLER=wshandler

appimage:
Expand All @@ -44,3 +46,4 @@ jobs:
- run: make appimage ARCH=x86_64 YQ_ARCH=amd64 WSHANDLER_VERSION=1.1.1
- run: make appimage ARCH=aarch64 YQ_ARCH=arm64
- run: make test WSHANDLER=./build/appimage/wshandler-x86_64.AppImage
- run: ./build/appimage/wshandler-x86_64.AppImage upgrade_appimage
33 changes: 28 additions & 5 deletions wshandler
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ help()
echo "wshandler installation commands:"
echo " install_test_deps"
echo " [-p|--policy {skip_yq}|snap|download] install <BIN_PATH {~/bin}>"
echo " upgrade <BIN_PATH {~/bin}>"
echo " upgrade_appimage <BIN_PATH {~/bin}>"

exit "${EXIT_CODE}"
}
Expand Down Expand Up @@ -715,6 +717,15 @@ snap_install()
sudo snap install "$@"
}

wsh_download()
{
if ! command -v "wget" > /dev/null
then
apt_install wget
fi
wget -O - "$@"
}


WSH_SOURCE_TYPES="git"
WSH_COMMAND_POLICY=default
Expand Down Expand Up @@ -846,11 +857,7 @@ do
snap_install yq
;;
download)
if ! command -v "wget" > /dev/null
then
apt_install wget
fi
wget -O - "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" \
wsh_download "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" \
| tar -zxO > "${BIN_PATH}/yq"
chmod +x "${BIN_PATH}/yq"
;;
Expand All @@ -861,6 +868,22 @@ do
fi
exit;;

upgrade)
BIN_PATH=${2:-"${HOME}/bin"}
mkdir -p "${BIN_PATH}"

wsh_download "https://github.com/asherikov/wshandler/releases/latest/download/wshandler" > "${BIN_PATH}/wshandler"
chmod +x "${BIN_PATH}/wshandler"
exit;;

upgrade_appimage)
BIN_PATH=${2:-"${HOME}/bin"}
mkdir -p "${BIN_PATH}"

wsh_download "https://github.com/asherikov/wshandler/releases/latest/download/wshandler-$(uname -m).AppImage" > "${BIN_PATH}/wshandler"
chmod +x "${BIN_PATH}/wshandler"
exit;;

*)
help 1;;
esac
Expand Down

0 comments on commit 352b7e9

Please sign in to comment.