Skip to content

Commit 028b60b

Browse files
authored
Merge pull request #183 from aws/pipeline
Continuous Delivery: Added scripts for Continuous Delivery and provide version stamping, Used a higher version of nexus-staging-maven-plugin to fix release issue
2 parents 93d4f29 + 7caf4b3 commit 028b60b

File tree

8 files changed

+100
-8
lines changed

8 files changed

+100
-8
lines changed

aws-iot-device-sdk-java-samples/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<parent>
44
<groupId>com.amazonaws</groupId>
55
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
6-
<version>1.3.9</version>
6+
<version>0.0.1-dev</version>
77
</parent>
88
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
99
<dependencies>
1010
<dependency>
1111
<groupId>com.amazonaws</groupId>
1212
<artifactId>aws-iot-device-sdk-java</artifactId>
13-
<version>1.3.9</version>
13+
<version>0.0.1-dev</version>
1414
</dependency>
1515
<dependency>
1616
<groupId>commons-codec</groupId>

aws-iot-device-sdk-java-samples/samples-pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.amazonaws</groupId>
44
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
5-
<version>1.3.9</version>
5+
<version>0.0.1-dev</version>
66
<dependencies>
77
<dependency>
88
<groupId>org.apache.maven.plugins</groupId>
@@ -12,7 +12,7 @@
1212
<dependency>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-iot-device-sdk-java</artifactId>
15-
<version>1.3.9</version>
15+
<version>0.0.1-dev</version>
1616
</dependency>
1717
<dependency>
1818
<groupId>com.fasterxml.jackson.core</groupId>

aws-iot-device-sdk-java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.amazonaws</groupId>
55
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
6-
<version>1.3.9</version>
6+
<version>0.0.1-dev</version>
77
</parent>
88
<artifactId>aws-iot-device-sdk-java</artifactId>
99
<dependencies>

aws-iot-device-sdk-java/src/main/java/com/amazonaws/services/iot/client/mqtt/AwsIotMqttConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
@Setter
4545
public class AwsIotMqttConnection extends AwsIotConnection {
4646

47-
private static final String USERNAME_METRIC_STRING = "?SDK=Java&Version=1.3.9";
47+
// Release Script will replace the version string on release. Refer to codebuild/cd/promote-release.yml
48+
private static final String USERNAME_METRIC_STRING = "?SDK=Java&Version=0.0.1-dev";
4849
private final SocketFactory socketFactory;
4950

5051
private MqttAsyncClient mqttClient;

codebuild/cd/promote-release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: 0.2
2+
#this buildspec assumes the ubuntu 16.04:x64 image
3+
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
4+
# into it once all platforms are built and artifacted
5+
phases:
6+
install:
7+
commands:
8+
- sudo add-apt-repository ppa:openjdk-r/ppa
9+
- sudo apt-get update -y
10+
- sudo apt-get install openjdk-8-jdk-headless maven -y -f
11+
- sudo apt-get install jq -y
12+
# need latest awscli for secretsmanager
13+
- sudo pip3 install awscli --upgrade
14+
15+
pre_build:
16+
commands:
17+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java
18+
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
19+
- echo PKG_VERSION=$PKG_VERSION
20+
# Set version to PKG_VERSION
21+
- sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' pom.xml
22+
- sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java/pom.xml
23+
- sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java-samples/pom.xml
24+
- sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java/src/main/java/com/amazonaws/services/iot/client/mqtt/AwsIotMqttConnection.java
25+
# Get java v1 gpg files
26+
- aws s3 cp --recursive s3://code-sharing-aws-crt/gpg-java-v1/ maven-gpg
27+
# manully copy the maven-gpg in subfolder, since codeBuild does not set localRepository correctly
28+
- cp -r maven-gpg aws-iot-device-sdk-java/maven-gpg
29+
- cp -r maven-gpg aws-iot-device-sdk-java-samples/maven-gpg
30+
# install settings.xml to ~/.m2/settings.xml
31+
- mkdir -p $HOME/.m2
32+
- aws s3 cp s3://code-sharing-aws-crt/iot-sdk-java-v1.settings.xml $HOME/.m2/settings.xml
33+
- aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/Password/V1 > sonatype_secret
34+
- jq fromjson sonatype_secret > sonatype_json
35+
- export ST_PASSWORD=$(jq -r '.password' sonatype_json)
36+
- export ST_USERNAME=$(jq -r '.username' sonatype_json)
37+
- aws --query "SecretString" secretsmanager get-secret-value --secret-id gpg/IoT/JAVA/V1 > gpg_secret
38+
- jq fromjson gpg_secret > gpg_json
39+
- export GPG_PRINCIPAL=$(jq -r '.username' gpg_json)
40+
- export GPG_CREDENTIAL=$(jq -r '.password' gpg_json)
41+
# Use the password from secret manager to update the settings
42+
- sed -i 's/sonatype_Principal/'"$ST_USERNAME"'/g' $HOME/.m2/settings.xml
43+
- sed -i 's/sonatype_Credential/'"$ST_PASSWORD"'/g' $HOME/.m2/settings.xml
44+
- sed -i 's/gpg_Principal/'"$GPG_PRINCIPAL"'/g' $HOME/.m2/settings.xml
45+
- sed -i 's/gpg_Credential/'"$GPG_CREDENTIAL"'/g' $HOME/.m2/settings.xml
46+
47+
48+
build:
49+
commands:
50+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java
51+
# Trigger the release of the last staged package in the staging repository
52+
- mvn -s $HOME/.m2/settings.xml clean package -Dmaven.test.skip=true
53+
- mvn -s $HOME/.m2/settings.xml clean deploy -P publishing -e -X
54+
- mvn -s $HOME/.m2/settings.xml nexus-staging:release -e -X
55+
56+
cache:
57+
paths:
58+
- "/root/.m2/**/*"
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 -e
3+
set -x
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=$(curl -s "https://repo.maven.apache.org/maven2/com/amazonaws/aws-iot-device-sdk-java/maven-metadata.xml" | grep "<latest>" | cut -f2 -d ">" | cut -f1 -d "<")
17+
if [ "$PUBLISHED_TAG_VERSION" == "$CURRENT_TAG_VERSION" ]; then
18+
echo "$CURRENT_TAG_VERSION is already in Sonatype, 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 Sonatype, 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+
#this build spec assumes the ubuntu 16.04:x64 image
3+
#this build run simply verifies we haven't published something at this tag yet.
4+
#if we have we fail the build and stop the pipeline, if we haven't we allow the pipeline to run.
5+
phases:
6+
build:
7+
commands:
8+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java
9+
- bash ./codebuild/cd/test-version-exists.sh
10+

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.amazonaws</groupId>
44
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
5-
<version>1.3.9</version>
5+
<version>0.0.1-dev</version>
66
<packaging>pom</packaging>
77
<name>AWS IoT Device SDK for Java</name>
88
<description>The AWS IoT Device SDK for Java provides Java APIs for devices to connect to AWS IoT service using the MQTT protocol. The SDK also provides support for AWS IoT specific features, such as Thing Shadow and Thing Shadow abstraction.</description>
@@ -45,7 +45,7 @@
4545
<plugin>
4646
<groupId>org.sonatype.plugins</groupId>
4747
<artifactId>nexus-staging-maven-plugin</artifactId>
48-
<version>1.6.3</version>
48+
<version>1.6.8</version>
4949
<extensions>true</extensions>
5050
<configuration>
5151
<serverId>ossrh</serverId>

0 commit comments

Comments
 (0)