Skip to content

Commit 352b7e9

Browse files
committed
Add upgrade commands
1 parent 5c03e13 commit 352b7e9

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/master.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- uses: actions/checkout@v4
2727
- run: ./wshandler install_test_deps
2828
- run: sudo ./wshandler --policy download install /usr/bin/
29+
- run: sudo ./wshandler upgrade /usr/bin/
2930
- run: make test WSHANDLER=wshandler
3031

3132
ubuntu22-snap-yq:
@@ -34,6 +35,7 @@ jobs:
3435
- uses: actions/checkout@v4
3536
- run: ./wshandler install_test_deps
3637
- run: sudo ./wshandler --policy snap install /usr/bin/
38+
- run: sudo ./wshandler upgrade /usr/bin/
3739
- run: make test WSHANDLER=wshandler
3840

3941
appimage:
@@ -44,3 +46,4 @@ jobs:
4446
- run: make appimage ARCH=x86_64 YQ_ARCH=amd64 WSHANDLER_VERSION=1.1.1
4547
- run: make appimage ARCH=aarch64 YQ_ARCH=arm64
4648
- run: make test WSHANDLER=./build/appimage/wshandler-x86_64.AppImage
49+
- run: ./build/appimage/wshandler-x86_64.AppImage upgrade_appimage

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)