Skip to content

Commit 0e47104

Browse files
committed
Add upgrade commands
1 parent 5c03e13 commit 0e47104

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

.github/workflows/master.yml

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
- run: ./wshandler install_test_deps
2828
- run: sudo ./wshandler --policy download install /usr/bin/
2929
- run: make test WSHANDLER=wshandler
30+
- run: sudo ./wshandler upgrade /usr/bin/
31+
- run: wshandler --version
3032

3133
ubuntu22-snap-yq:
3234
runs-on: ubuntu-22.04
@@ -35,6 +37,8 @@ jobs:
3537
- run: ./wshandler install_test_deps
3638
- run: sudo ./wshandler --policy snap install /usr/bin/
3739
- run: make test WSHANDLER=wshandler
40+
- run: sudo ./wshandler upgrade /usr/bin/
41+
- run: wshandler --version
3842

3943
appimage:
4044
runs-on: ubuntu-latest
@@ -44,3 +48,5 @@ jobs:
4448
- run: make appimage ARCH=x86_64 YQ_ARCH=amd64 WSHANDLER_VERSION=1.1.1
4549
- run: make appimage ARCH=aarch64 YQ_ARCH=arm64
4650
- run: make test WSHANDLER=./build/appimage/wshandler-x86_64.AppImage
51+
- run: sudo ./build/appimage/wshandler-x86_64.AppImage upgrade_appimage /usr/bin/
52+
- run: wshandler --version

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Package repository commands:
8585
wshandler installation commands:
8686
install_test_deps
8787
[-p|--policy {skip_yq}|snap|download] install <BIN_PATH {~/bin}>
88+
upgrade <BIN_PATH {~/bin}>
89+
upgrade_appimage <BIN_PATH {~/bin}>
8890
```
8991

9092
Examples

wshandler

+28-5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ help()
6767
echo "wshandler installation commands:"
6868
echo " install_test_deps"
6969
echo " [-p|--policy {skip_yq}|snap|download] install <BIN_PATH {~/bin}>"
70+
echo " upgrade <BIN_PATH {~/bin}>"
71+
echo " upgrade_appimage <BIN_PATH {~/bin}>"
7072

7173
exit "${EXIT_CODE}"
7274
}
@@ -715,6 +717,15 @@ snap_install()
715717
sudo snap install "$@"
716718
}
717719

720+
wsh_download()
721+
{
722+
if ! command -v "wget" > /dev/null
723+
then
724+
apt_install wget
725+
fi
726+
wget -O - "$@"
727+
}
728+
718729

719730
WSH_SOURCE_TYPES="git"
720731
WSH_COMMAND_POLICY=default
@@ -846,11 +857,7 @@ do
846857
snap_install yq
847858
;;
848859
download)
849-
if ! command -v "wget" > /dev/null
850-
then
851-
apt_install wget
852-
fi
853-
wget -O - "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" \
860+
wsh_download "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" \
854861
| tar -zxO > "${BIN_PATH}/yq"
855862
chmod +x "${BIN_PATH}/yq"
856863
;;
@@ -861,6 +868,22 @@ do
861868
fi
862869
exit;;
863870

871+
upgrade)
872+
BIN_PATH=${2:-"${HOME}/bin"}
873+
mkdir -p "${BIN_PATH}"
874+
875+
wsh_download "https://github.com/asherikov/wshandler/releases/latest/download/wshandler" > "${BIN_PATH}/wshandler"
876+
chmod +x "${BIN_PATH}/wshandler"
877+
exit;;
878+
879+
upgrade_appimage)
880+
BIN_PATH=${2:-"${HOME}/bin"}
881+
mkdir -p "${BIN_PATH}"
882+
883+
wsh_download "https://github.com/asherikov/wshandler/releases/latest/download/wshandler-$(uname -m).AppImage" > "${BIN_PATH}/wshandler"
884+
chmod +x "${BIN_PATH}/wshandler"
885+
exit;;
886+
864887
*)
865888
help 1;;
866889
esac

0 commit comments

Comments
 (0)