diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 39ddaec..81b15f0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -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: @@ -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: @@ -44,3 +46,5 @@ 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: sudo ./build/appimage/wshandler-x86_64.AppImage upgrade_appimage /usr/bin/ + - run: wshandler --version diff --git a/README.md b/README.md index 6167a11..9b03875 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ Package repository commands: wshandler installation commands: install_test_deps [-p|--policy {skip_yq}|snap|download] install + upgrade + upgrade_appimage ``` Examples diff --git a/wshandler b/wshandler index d5ee2da..a1c0bc5 100755 --- a/wshandler +++ b/wshandler @@ -67,6 +67,8 @@ help() echo "wshandler installation commands:" echo " install_test_deps" echo " [-p|--policy {skip_yq}|snap|download] install " + echo " upgrade " + echo " upgrade_appimage " exit "${EXIT_CODE}" } @@ -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 @@ -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" ;; @@ -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