-
Notifications
You must be signed in to change notification settings - Fork 4
/
install-cicd.bash
96 lines (85 loc) · 2.49 KB
/
install-cicd.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
set -e
echoerr() { echo "\$@" 1>&2; }
AUTIFY_CLI_VERSION=REPLACE
AUTIFY_S3_BUCKET=REPLACE
AUTIFY_S3_PREFIX=REPLACE
WORKSPACE="$(pwd)"
AUTIFY_DIR="$WORKSPACE/autify"
AUTIFY_PATH="$AUTIFY_DIR/path" # Export PATHs to use the installed commands.
if [ -n "$AUTIFY_CLI_INSTALL_USE_CACHE" ] && [ -d "$AUTIFY_DIR" ]; then
echo "$AUTIFY_DIR exists. Reuse it as cache."
exit
fi
rm -fr "$AUTIFY_DIR"
mkdir "$AUTIFY_DIR"
if [ "$(uname)" == "Darwin" ]; then
OS=darwin
elif [ "$(uname -s | cut -c 1-5)" == "Linux" ]; then
OS=linux
elif [ "$(uname -s | cut -c 1-5)" == "MINGW" ]; then
OS=windows
elif [ "$(uname -s | cut -c 1-4)" == "MSYS" ]; then
OS=windows
else
echoerr "Unsupported os: $(uname)"
exit 1
fi
ARCH="$(uname -m)"
if [ "$ARCH" == "x86_64" ]; then
ARCH=x64
elif [ "$ARCH" == "armv7l" ]; then
ARCH=arm
elif [ "$ARCH" == "aarch64" ]; then
ARCH=arm64
elif [ "$ARCH" == "arm64" ]; then
ARCH=arm64
else
echoerr "Unsupported arch: $ARCH"
exit 1
fi
if [ "$OS" == "windows" ]; then
URL="https://$AUTIFY_S3_BUCKET.s3.amazonaws.com/$AUTIFY_S3_PREFIX-$ARCH.exe"
echo "Installing CLI from $URL"
EXE_FILE="$AUTIFY_DIR/installer.exe"
curl "$URL" > "$EXE_FILE"
MSYS_NO_PATHCONV=1 cmd.exe /C "$(cygpath -w "$EXE_FILE") /S /D=$(cygpath -w "$AUTIFY_DIR")"
else
mkdir "$AUTIFY_DIR/bin"
mkdir "$AUTIFY_DIR/lib"
cd "$AUTIFY_DIR/lib"
if [ "$(command -v xz)" ]; then
TAR_EXT="tar.xz"
TAR_ARGS="xJ"
else
TAR_EXT="tar.gz"
TAR_ARGS="xz"
fi
URL="https://$AUTIFY_S3_BUCKET.s3.amazonaws.com/$AUTIFY_S3_PREFIX-$OS-$ARCH.$TAR_EXT"
echo "Installing CLI from $URL"
if [ "$(command -v curl)" ]; then
curl "$URL" | tar "$TAR_ARGS"
else
wget -O- "$URL" | tar "$TAR_ARGS"
fi
ln -s "$AUTIFY_DIR/lib/autify/bin/autify" "$AUTIFY_DIR/bin/autify"
fi
cd "$WORKSPACE"
"$AUTIFY_DIR/bin/autify" --version
echo "$AUTIFY_DIR/bin" >> "$AUTIFY_PATH"
if [ -n "$AUTIFY_CLI_INTEGRATION_TEST_INSTALL" ]; then
file_prefix=$(basename "$AUTIFY_S3_PREFIX")
dir_prefix=$(dirname "$AUTIFY_S3_PREFIX")
if [ "$file_prefix" == "autify" ]; then
# channel
package="autifyhq-autify-cli-integration-test.tgz"
else
# version
package="autifyhq-autify-cli-integration-test-$AUTIFY_CLI_VERSION.tgz"
fi
package_url="https://$AUTIFY_S3_BUCKET.s3.amazonaws.com/${dir_prefix}/${package}"
cd "$AUTIFY_DIR"
echo "Installing autify-cli-integration-test package from $package_url"
npm install "$package_url" --prefix "$AUTIFY_DIR"
echo "$AUTIFY_DIR/node_modules/.bin" >> "$AUTIFY_PATH"
fi