|
| 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/**/*" |
0 commit comments