@@ -7,6 +7,15 @@ PROJECT_GH="databus23/$PROJECT_NAME"
7
7
8
8
: ${HELM_PLUGIN_PATH:= " $( helm home) /plugins/helm-diff" }
9
9
10
+ # Convert the HELM_PLUGIN_PATH to unix if cygpath is
11
+ # available. This is the case when using MSYS2 or Cygwin
12
+ # on Windows where helm returns a Windows path but we
13
+ # need a Unix path
14
+
15
+ if type cygpath > /dev/null 2>&1 ; then
16
+ HELM_PLUGIN_PATH=$( cygpath -u $HELM_PLUGIN_PATH )
17
+ fi
18
+
10
19
if [[ $SKIP_BIN_INSTALL == " 1" ]]; then
11
20
echo " Skipping binary install"
12
21
exit
@@ -32,6 +41,8 @@ initOS() {
32
41
OS=$( echo ` uname` | tr ' [:upper:]' ' [:lower:]' )
33
42
34
43
case " $OS " in
44
+ # Msys support
45
+ msys* ) OS=' windows' ;;
35
46
# Minimalist GNU for Windows
36
47
mingw* ) OS=' windows' ;;
37
48
darwin) OS=' macos' ;;
@@ -41,7 +52,7 @@ initOS() {
41
52
# verifySupported checks that the os/arch combination is supported for
42
53
# binary builds.
43
54
verifySupported () {
44
- local supported=" linux-amd64\nmacos-amd64"
55
+ local supported=" linux-amd64\nmacos-amd64\nwindows-amd64 "
45
56
if ! echo " ${supported} " | grep -q " ${OS} -${ARCH} " ; then
46
57
echo " No prebuild binary for ${OS} -${ARCH} ."
47
58
exit 1
@@ -55,12 +66,16 @@ verifySupported() {
55
66
56
67
# getDownloadURL checks the latest available version.
57
68
getDownloadURL () {
58
- # Use the GitHub API to find the latest version for this project.
59
- local latest_url=" https://api.github.com/repos/$PROJECT_GH /releases/latest"
69
+ local url=" https://api.github.com/repos/$PROJECT_GH /releases/latest"
70
+ local version=$( git describe --tags --exact-match 2> /dev/null)
71
+ if [ -n " $version " ]; then
72
+ url=" https://api.github.com/repos/$PROJECT_GH /releases/tags/$version "
73
+ fi
74
+ # Use the GitHub API to find the download url for this project.
60
75
if type " curl" > /dev/null; then
61
- DOWNLOAD_URL=$( curl -s $latest_url | grep $OS | awk ' /\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}' )
76
+ DOWNLOAD_URL=$( curl -v - s $url | grep $OS | awk ' /\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}' )
62
77
elif type " wget" > /dev/null; then
63
- DOWNLOAD_URL=$( wget -q -O - $latest_url | grep $OS | awk ' /\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}' )
78
+ DOWNLOAD_URL=$( wget -q -O - $url | grep $OS | awk ' /\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}' )
64
79
fi
65
80
}
66
81
0 commit comments