Skip to content

Commit

Permalink
Deployment to Maven (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Boswell authored Jun 20, 2019
1 parent d6648f6 commit cdb2623
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 39 deletions.
46 changes: 46 additions & 0 deletions codebuild/cd/deploy-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 0.2
#this buildspec assumes the ubuntu 14.04 openjdk-8 image
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
# into it once all platforms are built and artifacted
phases:
install:
commands:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get update -y
- sudo apt-get install openjdk-8-jdk-headless maven -y -f
# need latest awscli for secretsmanager
- sudo pip3 install awscli --upgrade

pre_build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
# install settings.xml to ~/.m2/settings.xml
- mkdir -p $HOME/.m2
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.xml $HOME/.m2/settings.xml
# import gpg key
- aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
- gpg --import /tmp/aws-sdk-common-runtime.key.asc
- 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')
build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
# update the version to match the git tag, make a snapshot version we can test
- mvn -B versions:set -DnewVersion=${PKG_VERSION}-SNAPSHOT
# do a full build/deploy, but skip tests, since the shared libs were artifacts above
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE
# update the version to match the git tag, make a staging release which we will release once snapshot testing passes
- mvn -B versions:set -DnewVersion=${PKG_VERSION}
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE | tee /tmp/deploy.log
- cat /tmp/deploy.log | grep "Created staging repository with ID" | cut -d\" -f2 | tee /tmp/repositoryId.txt

artifacts:
discard-paths: yes
files:
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.jar
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.asc
- /tmp/repositoryId.txt

cache:
paths:
- '/root/.m2/**/*'
35 changes: 35 additions & 0 deletions codebuild/cd/promote-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 0.2
#this buildspec assumes the ubuntu 16.04:x64 image
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
# into it once all platforms are built and artifacted
phases:
install:
commands:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get update -y
- sudo apt-get install openjdk-8-jdk-headless maven -y -f
# need latest awscli for secretsmanager
- sudo pip3 install awscli --upgrade

pre_build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
- echo PKG_VERSION=$PKG_VERSION
# install settings.xml to ~/.m2/settings.xml
- mkdir -p $HOME/.m2
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.xml $HOME/.m2/settings.xml
# import gpg key
- aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
- gpg --import /tmp/aws-sdk-common-runtime.key.asc
- 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')
- export REPOSITORY_ID=$(cat $CODEBUILD_SRC_DIR_aws_iot_device_sdk_java_v2_jar/repositoryId.txt)
build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
# Trigger the release of the last staged package in the staging repository
- mvn -B nexus-staging:release -Prelease -DstagingRepositoryId=$REPOSITORY_ID

cache:
paths:
- '/root/.m2/**/*'
26 changes: 26 additions & 0 deletions codebuild/cd/test-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 0.2
#this buildspec assumes the ubuntu 16.04:x64 image
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
# into it once all platforms are built and artifacted
phases:
install:
commands:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get update -y
- sudo apt-get install openjdk-8-jdk-headless maven -y -f

pre_build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
- export PKG_VERSION=$(git describe --tags | sed -e s/^v//)

build:
commands:
# Verify that the package can be found in the snapshot repo
# note that this uses an ancient version of maven and the maven dependency plugin because we're on trusty
# http://maven.apache.org/plugins-archives/maven-dependency-plugin-2.1/get-mojo.html
- 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

cache:
paths:
- '/root/.m2/**/*'
23 changes: 23 additions & 0 deletions codebuild/cd/test-version-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
set -x
# force a failure if there's no tag
git describe --tags
# now get the tag
CURRENT_TAG=$(git describe --tags | cut -f2 -dv)
# convert v0.2.12-2-g50254a9 to 0.2.12
CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv)
# if there's a hash on the tag, then this is not a release tagged commit
if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then
echo "Current tag version is not a release tag, cut a new release if you want to publish."
exit 1
fi

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 "<")
if [ "$PUBLISHED_TAG_VERSION" == "$CURRENT_TAG_VERSION" ]; then
echo "$CURRENT_TAG_VERSION is already in Sonatype, cut a new tag if you want to upload another version."
exit 1
fi

echo "$CURRENT_TAG_VERSION currently does not exist in Sonatype, allowing pipeline to continue."
exit 0
10 changes: 10 additions & 0 deletions codebuild/cd/test-version-exists.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 0.2
#this build spec assumes the ubuntu 16.04:x64 image
#this build run simply verifies we haven't published something at this tag yet.
#if we have we fail the build and stop the pipeline, if we haven't we allow the pipeline to run.
phases:
build:
commands:
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
- bash ./codebuild/cd/test-version-exists.sh

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iot</groupId>
<artifactId>AwsIotSdkJava</artifactId>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>sdk</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>

Expand Down
6 changes: 4 additions & 2 deletions samples/BasicPubSub/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iot</groupId>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>BasicPubSub</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java bindings for the AWS IoT Core Service</description>
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
6 changes: 4 additions & 2 deletions samples/Jobs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iot</groupId>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>Jobs</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java bindings for the AWS IoT Core Service</description>
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
6 changes: 4 additions & 2 deletions samples/Shadow/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iot</groupId>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>Shadow</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java bindings for the AWS IoT Core Service</description>
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
162 changes: 131 additions & 31 deletions sdk/pom.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,134 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iot</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk.crt</groupId>
<artifactId>aws-crt-java</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>aws-iot-device-sdk</artifactId>
<packaging>jar</packaging>
<version>0.2-SNAPSHOT</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java bindings for the AWS IoT Core Service</description>
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>AWS SDK Common Runtime Team</name>
<email>[email protected]</email>
<organization>Amazon Web Services</organization>
<organizationUrl>https://aws.amazon.com</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/awslabs/aws-iot-device-sdk-java-v2.git</connection>
<developerConnection>scm:git:ssh://github.com:awslabs/aws-iot-device-sdk-java-v2.git</developerConnection>
<url>http://github.com/awslabs/aws-iot-device-sdk-java-v2/tree/master</url>
</scm>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>software.amazon.awssdk.crt</groupId>
<artifactId>aws-crt</artifactId>
<version>0.3.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>compile</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>release</id>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- staging/release to Sonatype -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- source jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- javadoc jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG signing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>${gpg.keyname}</keyname>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit cdb2623

Please sign in to comment.