Skip to content

Commit cdb2623

Browse files
author
Justin Boswell
authored
Deployment to Maven (#11)
1 parent d6648f6 commit cdb2623

10 files changed

Lines changed: 285 additions & 39 deletions

File tree

codebuild/cd/deploy-snapshot.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: 0.2
2+
#this buildspec assumes the ubuntu 14.04 openjdk-8 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+
# need latest awscli for secretsmanager
12+
- sudo pip3 install awscli --upgrade
13+
14+
pre_build:
15+
commands:
16+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
17+
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
18+
# install settings.xml to ~/.m2/settings.xml
19+
- mkdir -p $HOME/.m2
20+
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.xml $HOME/.m2/settings.xml
21+
# import gpg key
22+
- aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
23+
- gpg --import /tmp/aws-sdk-common-runtime.key.asc
24+
- export GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id aws-sdk-common-runtime.key.asc/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
25+
build:
26+
commands:
27+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
28+
# update the version to match the git tag, make a snapshot version we can test
29+
- mvn -B versions:set -DnewVersion=${PKG_VERSION}-SNAPSHOT
30+
# do a full build/deploy, but skip tests, since the shared libs were artifacts above
31+
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE
32+
# update the version to match the git tag, make a staging release which we will release once snapshot testing passes
33+
- mvn -B versions:set -DnewVersion=${PKG_VERSION}
34+
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE | tee /tmp/deploy.log
35+
- cat /tmp/deploy.log | grep "Created staging repository with ID" | cut -d\" -f2 | tee /tmp/repositoryId.txt
36+
37+
artifacts:
38+
discard-paths: yes
39+
files:
40+
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.jar
41+
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.asc
42+
- /tmp/repositoryId.txt
43+
44+
cache:
45+
paths:
46+
- '/root/.m2/**/*'

codebuild/cd/promote-release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
# need latest awscli for secretsmanager
12+
- sudo pip3 install awscli --upgrade
13+
14+
pre_build:
15+
commands:
16+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
17+
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
18+
- echo PKG_VERSION=$PKG_VERSION
19+
# install settings.xml to ~/.m2/settings.xml
20+
- mkdir -p $HOME/.m2
21+
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.xml $HOME/.m2/settings.xml
22+
# import gpg key
23+
- aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
24+
- gpg --import /tmp/aws-sdk-common-runtime.key.asc
25+
- export GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id aws-sdk-common-runtime.key.asc/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
26+
- export REPOSITORY_ID=$(cat $CODEBUILD_SRC_DIR_aws_iot_device_sdk_java_v2_jar/repositoryId.txt)
27+
build:
28+
commands:
29+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
30+
# Trigger the release of the last staged package in the staging repository
31+
- mvn -B nexus-staging:release -Prelease -DstagingRepositoryId=$REPOSITORY_ID
32+
33+
cache:
34+
paths:
35+
- '/root/.m2/**/*'

codebuild/cd/test-snapshot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
12+
pre_build:
13+
commands:
14+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
15+
- export PKG_VERSION=$(git describe --tags | sed -e s/^v//)
16+
17+
build:
18+
commands:
19+
# Verify that the package can be found in the snapshot repo
20+
# note that this uses an ancient version of maven and the maven dependency plugin because we're on trusty
21+
# http://maven.apache.org/plugins-archives/maven-dependency-plugin-2.1/get-mojo.html
22+
- mvn -B dependency:get -DrepoUrl=https://oss.sonatype.org/content/repositories/snapshots -Dartifact=software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk:${PKG_VERSION}-SNAPSHOT -Dtransitive=false
23+
24+
cache:
25+
paths:
26+
- '/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/software/amazon/awssdk/iotdevicesdk/aws-iot-device-sdk/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-v2
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
@@ -1,8 +1,8 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>software.amazon.awssdk.iot</groupId>
5-
<artifactId>AwsIotSdkJava</artifactId>
4+
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
5+
<artifactId>sdk</artifactId>
66
<packaging>pom</packaging>
77
<version>1.0-SNAPSHOT</version>
88

samples/BasicPubSub/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>software.amazon.awssdk.iot</groupId>
4+
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
55
<artifactId>BasicPubSub</artifactId>
66
<packaging>jar</packaging>
77
<version>1.0-SNAPSHOT</version>
8-
<url>http://maven.apache.org</url>
8+
<name>${project.groupId}:${project.artifactId}</name>
9+
<description>Java bindings for the AWS IoT Core Service</description>
10+
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
911
<properties>
1012
<maven.compiler.source>1.8</maven.compiler.source>
1113
<maven.compiler.target>1.8</maven.compiler.target>

samples/Jobs/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>software.amazon.awssdk.iot</groupId>
4+
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
55
<artifactId>Jobs</artifactId>
66
<packaging>jar</packaging>
77
<version>1.0-SNAPSHOT</version>
8-
<url>http://maven.apache.org</url>
8+
<name>${project.groupId}:${project.artifactId}</name>
9+
<description>Java bindings for the AWS IoT Core Service</description>
10+
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
911
<properties>
1012
<maven.compiler.source>1.8</maven.compiler.source>
1113
<maven.compiler.target>1.8</maven.compiler.target>

samples/Shadow/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>software.amazon.awssdk.iot</groupId>
4+
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
55
<artifactId>Shadow</artifactId>
66
<packaging>jar</packaging>
77
<version>1.0-SNAPSHOT</version>
8-
<url>http://maven.apache.org</url>
8+
<name>${project.groupId}:${project.artifactId}</name>
9+
<description>Java bindings for the AWS IoT Core Service</description>
10+
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
911
<properties>
1012
<maven.compiler.source>1.8</maven.compiler.source>
1113
<maven.compiler.target>1.8</maven.compiler.target>

sdk/pom.xml

Lines changed: 131 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,134 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>software.amazon.awssdk.iot</groupId>
5-
<artifactId>aws-iot-device-sdk-java</artifactId>
6-
<packaging>jar</packaging>
7-
<version>1.0-SNAPSHOT</version>
8-
<url>http://maven.apache.org</url>
9-
<properties>
10-
<maven.compiler.source>1.8</maven.compiler.source>
11-
<maven.compiler.target>1.8</maven.compiler.target>
12-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
</properties>
14-
<dependencies>
15-
<dependency>
16-
<groupId>software.amazon.awssdk.crt</groupId>
17-
<artifactId>aws-crt-java</artifactId>
18-
<version>1.0</version>
19-
<scope>compile</scope>
20-
</dependency>
21-
<dependency>
22-
<groupId>junit</groupId>
23-
<artifactId>junit</artifactId>
24-
<version>4.12</version>
25-
<scope>test</scope>
26-
</dependency>
27-
<dependency>
28-
<groupId>com.google.code.gson</groupId>
29-
<artifactId>gson</artifactId>
30-
<version>2.8.5</version>
31-
<scope>compile</scope>
32-
</dependency>
33-
</dependencies>
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
5+
<artifactId>aws-iot-device-sdk</artifactId>
6+
<packaging>jar</packaging>
7+
<version>0.2-SNAPSHOT</version>
8+
<name>${project.groupId}:${project.artifactId}</name>
9+
<description>Java bindings for the AWS IoT Core Service</description>
10+
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
11+
12+
<licenses>
13+
<license>
14+
<name>The Apache Software License, Version 2.0</name>
15+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
16+
</license>
17+
</licenses>
18+
19+
<developers>
20+
<developer>
21+
<name>AWS SDK Common Runtime Team</name>
22+
<email>aws-sdk-common-runtime@amazon.com</email>
23+
<organization>Amazon Web Services</organization>
24+
<organizationUrl>https://aws.amazon.com</organizationUrl>
25+
</developer>
26+
</developers>
27+
28+
<scm>
29+
<connection>scm:git:git://github.com/awslabs/aws-iot-device-sdk-java-v2.git</connection>
30+
<developerConnection>scm:git:ssh://github.com:awslabs/aws-iot-device-sdk-java-v2.git</developerConnection>
31+
<url>http://github.com/awslabs/aws-iot-device-sdk-java-v2/tree/master</url>
32+
</scm>
33+
34+
<properties>
35+
<maven.compiler.source>1.8</maven.compiler.source>
36+
<maven.compiler.target>1.8</maven.compiler.target>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>software.amazon.awssdk.crt</groupId>
43+
<artifactId>aws-crt</artifactId>
44+
<version>0.3.8</version>
45+
<scope>compile</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>junit</groupId>
49+
<artifactId>junit</artifactId>
50+
<version>4.12</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.google.code.gson</groupId>
55+
<artifactId>gson</artifactId>
56+
<version>2.8.5</version>
57+
<scope>compile</scope>
58+
</dependency>
59+
</dependencies>
60+
61+
<profiles>
62+
<profile>
63+
<id>release</id>
64+
<distributionManagement>
65+
<snapshotRepository>
66+
<id>ossrh</id>
67+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
68+
</snapshotRepository>
69+
</distributionManagement>
70+
<build>
71+
<plugins>
72+
<!-- staging/release to Sonatype -->
73+
<plugin>
74+
<groupId>org.sonatype.plugins</groupId>
75+
<artifactId>nexus-staging-maven-plugin</artifactId>
76+
<version>1.6.8</version>
77+
<extensions>true</extensions>
78+
<configuration>
79+
<serverId>ossrh</serverId>
80+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
81+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
82+
</configuration>
83+
</plugin>
84+
<!-- source jar -->
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-source-plugin</artifactId>
88+
<version>2.2.1</version>
89+
<executions>
90+
<execution>
91+
<id>attach-sources</id>
92+
<goals>
93+
<goal>jar-no-fork</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
<!-- javadoc jar -->
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-javadoc-plugin</artifactId>
102+
<version>2.9.1</version>
103+
<executions>
104+
<execution>
105+
<id>attach-javadocs</id>
106+
<goals>
107+
<goal>jar</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
<!-- GPG signing -->
113+
<plugin>
114+
<groupId>org.apache.maven.plugins</groupId>
115+
<artifactId>maven-gpg-plugin</artifactId>
116+
<version>1.5</version>
117+
<executions>
118+
<execution>
119+
<id>sign-artifacts</id>
120+
<phase>verify</phase>
121+
<goals>
122+
<goal>sign</goal>
123+
</goals>
124+
<configuration>
125+
<keyname>${gpg.keyname}</keyname>
126+
</configuration>
127+
</execution>
128+
</executions>
129+
</plugin>
130+
</plugins>
131+
</build>
132+
</profile>
133+
</profiles>
34134
</project>

0 commit comments

Comments
 (0)