diff --git a/codebuild/cd/deploy-snapshot.yml b/codebuild/cd/deploy-snapshot.yml new file mode 100644 index 000000000..b7cc04458 --- /dev/null +++ b/codebuild/cd/deploy-snapshot.yml @@ -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/**/*' diff --git a/codebuild/cd/promote-release.yml b/codebuild/cd/promote-release.yml new file mode 100644 index 000000000..55eff6673 --- /dev/null +++ b/codebuild/cd/promote-release.yml @@ -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/**/*' diff --git a/codebuild/cd/test-snapshot.yml b/codebuild/cd/test-snapshot.yml new file mode 100644 index 000000000..115175806 --- /dev/null +++ b/codebuild/cd/test-snapshot.yml @@ -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/**/*' diff --git a/codebuild/cd/test-version-exists.sh b/codebuild/cd/test-version-exists.sh new file mode 100644 index 000000000..3b681bc55 --- /dev/null +++ b/codebuild/cd/test-version-exists.sh @@ -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 "" | 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 diff --git a/codebuild/cd/test-version-exists.yml b/codebuild/cd/test-version-exists.yml new file mode 100644 index 000000000..eaa0a938a --- /dev/null +++ b/codebuild/cd/test-version-exists.yml @@ -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 + diff --git a/pom.xml b/pom.xml index 20262da57..ba50984b6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,8 @@ 4.0.0 - software.amazon.awssdk.iot - AwsIotSdkJava + software.amazon.awssdk.iotdevicesdk + sdk pom 1.0-SNAPSHOT diff --git a/samples/BasicPubSub/pom.xml b/samples/BasicPubSub/pom.xml index 7412af14a..bd5bde383 100644 --- a/samples/BasicPubSub/pom.xml +++ b/samples/BasicPubSub/pom.xml @@ -1,11 +1,13 @@ 4.0.0 - software.amazon.awssdk.iot + software.amazon.awssdk.iotdevicesdk BasicPubSub jar 1.0-SNAPSHOT - http://maven.apache.org + ${project.groupId}:${project.artifactId} + Java bindings for the AWS IoT Core Service + https://github.com/awslabs/aws-iot-device-sdk-java-v2 1.8 1.8 diff --git a/samples/Jobs/pom.xml b/samples/Jobs/pom.xml index 633df375d..076f54050 100644 --- a/samples/Jobs/pom.xml +++ b/samples/Jobs/pom.xml @@ -1,11 +1,13 @@ 4.0.0 - software.amazon.awssdk.iot + software.amazon.awssdk.iotdevicesdk Jobs jar 1.0-SNAPSHOT - http://maven.apache.org + ${project.groupId}:${project.artifactId} + Java bindings for the AWS IoT Core Service + https://github.com/awslabs/aws-iot-device-sdk-java-v2 1.8 1.8 diff --git a/samples/Shadow/pom.xml b/samples/Shadow/pom.xml index 64d7fca02..291251813 100644 --- a/samples/Shadow/pom.xml +++ b/samples/Shadow/pom.xml @@ -1,11 +1,13 @@ 4.0.0 - software.amazon.awssdk.iot + software.amazon.awssdk.iotdevicesdk Shadow jar 1.0-SNAPSHOT - http://maven.apache.org + ${project.groupId}:${project.artifactId} + Java bindings for the AWS IoT Core Service + https://github.com/awslabs/aws-iot-device-sdk-java-v2 1.8 1.8 diff --git a/sdk/pom.xml b/sdk/pom.xml index f940b2d12..0e46d329d 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -1,34 +1,134 @@ -4.0.0 -software.amazon.awssdk.iot -aws-iot-device-sdk-java -jar -1.0-SNAPSHOT -http://maven.apache.org - - 1.8 - 1.8 - UTF-8 - - - - software.amazon.awssdk.crt - aws-crt-java - 1.0 - compile - - - junit - junit - 4.12 - test - - - com.google.code.gson - gson - 2.8.5 - compile - - + 4.0.0 + software.amazon.awssdk.iotdevicesdk + aws-iot-device-sdk + jar + 0.2-SNAPSHOT + ${project.groupId}:${project.artifactId} + Java bindings for the AWS IoT Core Service + https://github.com/awslabs/aws-iot-device-sdk-java-v2 + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + AWS SDK Common Runtime Team + aws-sdk-common-runtime@amazon.com + Amazon Web Services + https://aws.amazon.com + + + + + scm:git:git://github.com/awslabs/aws-iot-device-sdk-java-v2.git + scm:git:ssh://github.com:awslabs/aws-iot-device-sdk-java-v2.git + http://github.com/awslabs/aws-iot-device-sdk-java-v2/tree/master + + + + 1.8 + 1.8 + UTF-8 + + + + + software.amazon.awssdk.crt + aws-crt + 0.3.8 + compile + + + junit + junit + 4.12 + test + + + com.google.code.gson + gson + 2.8.5 + compile + + + + + + release + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + false + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + ${gpg.keyname} + + + + + + + +