-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtest-publish.sh
More file actions
executable file
·58 lines (48 loc) · 1.62 KB
/
test-publish.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.62 KB
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
#!/usr/bin/env bash
set -ex
VERSION_FILE_PATH=$1
if [ ! readlink -e "$VERSION_FILE_PATH" ]; then
echo "No VERSION file found! Cannot make release!"
exit 1
else
echo "VERSION file found..."
fi
VERSION=$(cat $VERSION_FILE_PATH)
# Make sure the version variable is populated
if [ -z "${VERSION}" ]; then
echo "VERSION file is empty!"
exit 1
else
echo "VERSION file contains: ${VERSION}"
fi
# Make sure the version follows the correct format: major.minor.patch
LENGTH_CHECK="${VERSION//[^.]}"
if [ ${#LENGTH_CHECK} != 2 ]; then
echo "VERSION file contains invalid version (not in format major.minor.patch)"
exit 1
fi
# Use RegX to ensure it only contains numbers and periods
REGX_CHECK='^([0-9]+\.){0,2}(\*|[0-9]+)$'
if [[ $VERSION =~ $REGX_CHECK ]]; then
echo "VERSION file contains valid version"
else
echo "VERSION file contains invalid version (RegX validator failed)"
exit 1
fi
PUBLISHED_TAG_VERSION=`npm show aws-iot-device-sdk-v2 version`
if [ "$PUBLISHED_TAG_VERSION" == "$VERSION" ]; then
echo "$VERSION found in npm. Testing release..."
# install the Typescript and the SDK
npm install -g typescript
npm install
# Move to the sample folder and get the endpoint
cd samples/node/mqtt/mqtt5_x509
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --region us-east-1 --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
# Run the sample!
npm install
node dist/index.js --endpoint $ENDPOINT --cert /tmp/certificate.pem --key /tmp/privatekey.pem
exit 0
else
echo "$VERSION was not found in npm. Release failed!"
fi
exit 1