Skip to content

Commit 6e744ad

Browse files
Working pub sub sample, CD scripts. (#13)
* Working pub sub sample, CD scripts.
1 parent a04d76c commit 6e744ad

16 files changed

+2461
-7105
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
samples
2+
node_modules
3+
.github
4+
continuous-delivery
5+
.npmrc

continuous-delivery/publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 0.2
2+
phases:
3+
install:
4+
runtime-versions:
5+
nodejs: 10
6+
build:
7+
commands:
8+
- cd $CODEBUILD_SRC_DIR
9+
- aws secretsmanager get-secret-value --secret-id prod/npm-registry/.npmrc --region us-east-1 | jq -r .SecretString > .npmrc
10+
- npm install
11+
- npm pack
12+
- npm --userconfig ./.npmrc publish aws-iot-device-sdk-js-v2*.tgz

continuous-delivery/test-publish.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# force a failure if there's no tag
5+
git describe --tags
6+
# now get the tag
7+
CURRENT_TAG=$(git describe --tags | cut -f2 -dv)
8+
# convert v0.2.12-2-g50254a9 to 0.2.12
9+
CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv)
10+
# if there's a hash on the tag, then this is not a release tagged commit
11+
if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then
12+
echo "Current tag version is not a release tag, cut a new release if you want to publish."
13+
exit 1
14+
fi
15+
16+
PUBLISHED_TAG_VERSION=`npm show aws-iot-device-sdk-v2 version`
17+
if [ "$PUBLISHED_TAG_VERSION" == "$CURRENT_TAG_VERSION" ]; then
18+
echo "$CURRENT_TAG_VERSION is already in npm, cut a new tag if you want to upload another version."
19+
20+
curl https://www.amazontrust.com/repository/AmazonRootCA1.pem --output /tmp/AmazonRootCA1.pem
21+
cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$cert" > /tmp/certificate.pem
22+
key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$key" > /tmp/privatekey.pem
23+
endpoint=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
24+
25+
cd samples/node/pub_sub
26+
npm install
27+
npm run tsc
28+
node dist/index.js --ca_file /tmp/AmazonRootCA1.pem --cert /tmp/certificate.pem --key /tmp/privatekey.pem --endpoint $endpoint --client_id prod_nodejs_test --verbosity info
29+
30+
exit 0
31+
fi
32+
33+
exit 1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# force a failure if there's no tag
5+
git describe --tags
6+
# now get the tag
7+
CURRENT_TAG=$(git describe --tags | cut -f2 -dv)
8+
# convert v0.2.12-2-g50254a9 to 0.2.12
9+
CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv)
10+
# if there's a hash on the tag, then this is not a release tagged commit
11+
if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then
12+
echo "Current tag version is not a release tag, cut a new release if you want to publish."
13+
exit 1
14+
fi
15+
16+
PUBLISHED_TAG_VERSION=`npm show aws-iot-device-sdk-v2 version`
17+
if [ "$PUBLISHED_TAG_VERSION" == "$CURRENT_TAG_VERSION" ]; then
18+
echo "$CURRENT_TAG_VERSION is already in npm, cut a new tag if you want to upload another version."
19+
exit 1
20+
fi
21+
22+
echo "$CURRENT_TAG_VERSION currently does not exist in npm, allowing pipeline to continue."
23+
exit 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 0.2
2+
phases:
3+
install:
4+
runtime-versions:
5+
nodejs: 10
6+
build:
7+
commands:
8+
- cd $CODEBUILD_SRC_DIR
9+
- bash ./continuous-delivery/test-version-exists.sh
10+

continuous-delivery/test_publish.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 0.2
2+
phases:
3+
install:
4+
runtime-versions:
5+
nodejs: 10
6+
build:
7+
commands:
8+
- echo Build started on `date`
9+
- cd $CODEBUILD_SRC_DIR
10+
- continuous-delivery/test_publish.sh

package-lock.json

Lines changed: 51 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
{
22
"name": "aws-iot-device-sdk-v2",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "NodeJS API for the AWS IoT service",
55
"homepage": "https://github.com/aws/aws-iot-device-sdk-js-v2",
6-
"repository": "github:aws/aws-iot-device-sdk-js-v2",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/aws/aws-iot-device-sdk-js-v2.git"
9+
},
10+
"keywords": [
11+
"aws",
12+
"iot"
13+
],
714
"contributors": [
815
"AWS SDK Common Runtime Team <[email protected]>"
916
],
1017
"license": "Apache-2.0",
1118
"main": "./dist/index.js",
1219
"scripts": {
1320
"tsc": "tsc",
14-
"prepare": "npm run tsc"
21+
"prepare": "npm run tsc",
22+
"build": "tsc"
1523
},
1624
"devDependencies": {
17-
"@types/node": "^10.12.18",
18-
"typescript": "^3.2.2"
25+
"@types/node": "^10.17.13",
26+
"typescript": "^3.7.3"
1927
},
2028
"dependencies": {
21-
"aws-crt": "^1.0.0"
29+
"aws-crt": "^1.0.4",
30+
"tsc": "^1.20150623.0"
2231
}
2332
}

samples/node/basic_discovery/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
import { mqtt, io, iot } from 'aws-crt';
16-
import { greengrass } from 'aws-iot-device-sdk';
16+
import { greengrass } from 'aws-iot-device-sdk-v2';
1717
import { TextDecoder } from 'util';
1818

1919
type Args = { [index: string]: any };

0 commit comments

Comments
 (0)