1
- #! /bin/bash -e
2
- # # Tested with https://www.shellcheck.net/
1
+ #! /bin/sh -e
2
+ # # Tested with https://www.shellcheck.net/
3
3
# Usage: (install latest)
4
4
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | sh
5
5
# or
6
6
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | sh
7
7
#
8
- # Usage: (install fixed version) - pass tag =v<tag > eg tag =v1.92.0 or set as an env var
9
- # $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | tag =v1.92.0 sh
8
+ # Usage: (install fixed version) - pass PACT_CLI_VERSION =v<PACT_CLI_VERSION > eg PACT_CLI_VERSION =v1.92.0 or set as an env var
9
+ # $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION =v1.92.0 sh
10
10
# or
11
- # $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | tag =v1.92.0 sh
11
+ # $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | PACT_CLI_VERSION =v1.92.0 sh
12
12
#
13
+ if [ " $tag " ]; then
14
+ echo " setting $tag as PACT_CLI_VERSION for legacy reasons"
15
+ PACT_CLI_VERSION=" $tag "
16
+ fi
13
17
14
- if [[ -z " $tag " ] ]; then
15
- tag =$( basename " $( curl -fs -o/dev/null -w " %{redirect_url}" https://github.com/pact-foundation/pact-ruby-standalone/releases/latest) " )
16
- echo " Thanks for downloading the latest release of pact-ruby-standalone $tag ."
18
+ if [ -z " $PACT_CLI_VERSION " ]; then
19
+ PACT_CLI_VERSION =$( basename " $( curl -fs -o/dev/null -w " %{redirect_url}" https://github.com/pact-foundation/pact-ruby-standalone/releases/latest) " )
20
+ echo " Thanks for downloading the latest release of pact-ruby-standalone $PACT_CLI_VERSION ."
17
21
echo " -----"
18
22
echo " Note:"
19
23
echo " -----"
20
- echo " You can download a fixed version by setting the tag environment variable eg tag =v1.92.0"
24
+ echo " You can download a fixed version by setting the PACT_CLI_VERSION environment variable eg PACT_CLI_VERSION =v1.92.0"
21
25
echo " example:"
22
- echo " curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | tag =v1.92.0 sh"
26
+ echo " curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION =v1.92.0 sh"
23
27
else
24
- echo " Thanks for downloading pact-ruby-standalone $tag ."
28
+ echo " Thanks for downloading pact-ruby-standalone $PACT_CLI_VERSION ."
25
29
fi
26
30
27
- TAG_WITHOUT_V =${tag # v}
28
- MAJOR_TAG =$( echo " $TAG_WITHOUT_V " | cut -d ' .' -f 1)
31
+ PACT_CLI_VERSION_WITHOUT_V =${PACT_CLI_VERSION # v}
32
+ MAJOR_PACT_CLI_VERSION =$( echo " $PACT_CLI_VERSION_WITHOUT_V " | cut -d ' .' -f 1)
29
33
30
34
case $( uname -sm) in
31
- ' Linux x86_64' )
32
- os=' linux-x86_64'
33
- ;;
34
- ' Linux aarch64' )
35
- if [[ " $MAJOR_TAG " -lt 2 ]]; then
36
- echo " Sorry, you'll need to install the pact-ruby-standalone manually."
37
- exit 1
38
- else
39
- os=' linux-arm64'
40
- fi
41
- ;;
42
- ' Darwin arm64' )
43
- if [[ " $MAJOR_TAG " -lt 2 ]]; then
44
- os=' osx'
45
- else
46
- os=' osx-arm64'
47
- fi
48
- ;;
49
- ' Darwin x86' | ' Darwin x86_64' )
50
- if [[ " $MAJOR_TAG " -lt 2 ]]; then
51
- os=' osx'
52
- else
53
- os=' osx-x86_64'
54
- fi
55
-
56
- ;;
57
- * )
35
+ ' Linux x86_64' )
36
+ os=' linux-x86_64'
37
+ ;;
38
+ ' Linux aarch64' )
39
+ if [ " $MAJOR_PACT_CLI_VERSION " -lt 2 ]; then
40
+ echo " Sorry, you'll need to install the pact-ruby-standalone manually."
41
+ exit 1
42
+ else
43
+ os=' linux-arm64'
44
+ fi
45
+ ;;
46
+ ' Darwin arm64' )
47
+ if [ " $MAJOR_PACT_CLI_VERSION " -lt 2 ]; then
48
+ os=' osx'
49
+ else
50
+ os=' osx-arm64'
51
+ fi
52
+ ;;
53
+ ' Darwin x86' | ' Darwin x86_64' )
54
+ if [ " $MAJOR_PACT_CLI_VERSION " -lt 2 ]; then
55
+ os=' osx'
56
+ else
57
+ os=' osx-x86_64'
58
+ fi
59
+ ;;
60
+ " Windows" * | " MINGW64" * )
61
+ if [ " $MAJOR_PACT_CLI_VERSION " -lt 2 ]; then
62
+ os=' win32'
63
+ else
64
+ os=' windows-x86_64'
65
+ fi
66
+ ;;
67
+ * )
58
68
echo " Sorry, you'll need to install the pact-ruby-standalone manually."
59
69
exit 1
60
- ;;
70
+ ;;
61
71
esac
62
72
73
+ case $os in
74
+ ' windows' * | ' win32' )
75
+ filename=" pact-${PACT_CLI_VERSION# v} -${os} .zip"
76
+ ;;
77
+ ' osx' * | ' linux' * )
78
+ filename=" pact-${PACT_CLI_VERSION# v} -${os} .tar.gz"
79
+ ;;
80
+ esac
63
81
64
- filename=" pact-${tag# v} -${os} .tar.gz"
65
82
echo " -------------"
66
83
echo " Downloading:"
67
84
echo " -------------"
68
- (curl -sLO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/" ${tag} " /" ${filename} " && echo downloaded " ${filename} " ) || (echo " Sorry, you'll need to install the pact-ruby-standalone manually." && exit 1)
69
- (tar xzf " ${filename} " && echo unarchived " ${filename} " ) || (echo " Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
85
+ (curl -sLO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/" ${PACT_CLI_VERSION} " /" ${filename} " && echo downloaded " ${filename} " ) || (echo " Sorry, you'll need to install the pact-ruby-standalone manually." && exit 1)
86
+ case $os in
87
+ ' windows' * | ' win32' )
88
+ (unzip " ${filename} " && echo unarchived " ${filename} " ) || (echo " Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
89
+ ;;
90
+ ' osx' * | ' linux' * )
91
+ (tar xzf " ${filename} " && echo unarchived " ${filename} " ) || (echo " Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
92
+ ;;
93
+ esac
70
94
(rm " ${filename} " && echo removed " ${filename} " ) || (echo " Sorry, you'll need to remove the pact-ruby-standalone archive manually." && exit 1)
71
- echo " pact-ruby-standalone ${tag} installed to $( pwd) /pact"
95
+
96
+ echo " pact-ruby-standalone ${PACT_CLI_VERSION} installed to $( pwd) /pact"
72
97
echo " -------------------"
73
98
echo " available commands:"
74
99
echo " -------------------"
75
- ls -1 " $( pwd) " /pact/bin
100
+ PROJECT_NAME=pact-cli
101
+ PACT_CLI_BIN_PATH=${PWD} /pact/bin/
102
+
103
+ ls -1 " $PACT_CLI_BIN_PATH "
104
+
105
+
106
+ if [ " $GITHUB_ENV " ]; then
107
+ echo " Added the following to your path to make ${PROJECT_NAME} available:"
108
+ echo " "
109
+ echo " PATH=$PACT_CLI_BIN_PATH :\$ {PATH}"
110
+ echo " PATH=$PACT_CLI_BIN_PATH :${PATH} " >> " $GITHUB_ENV "
111
+ elif [ " $CIRRUS_CI " ]; then
112
+ echo " Added the following to your path to make ${PROJECT_NAME} available:"
113
+ echo " "
114
+ echo " PATH=$PACT_CLI_BIN_PATH :\$ {PATH}"
115
+ echo " PATH=$PACT_CLI_BIN_PATH :${PATH} " >> " $CIRRUS_ENV "
116
+ else
117
+ echo " Add the following to your path to make ${PROJECT_NAME} available:"
118
+ echo " --- Linux/MacOS/Windows Bash Users --------"
119
+ echo " "
120
+ echo " PATH=:$PACT_CLI_BIN_PATH :\$ {PATH}"
121
+ fi
0 commit comments