|
| 1 | +version: 0.2 |
| 2 | +# this buildspec assumes the ubuntu image |
| 3 | +# This job is responsible for deploying and test a snapshot version of the aws-crt-java library |
| 4 | +phases: |
| 5 | + install: |
| 6 | + commands: |
| 7 | + - sudo add-apt-repository ppa:openjdk-r/ppa |
| 8 | + - sudo apt-get update -y |
| 9 | + - sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f |
| 10 | + pre_build: |
| 11 | + commands: |
| 12 | + - cd $CODEBUILD_SRC_DIR/aws-crt-java |
| 13 | + - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) |
| 14 | + - echo $PKG_VERSION |
| 15 | + - mkdir -p target/cmake-build/lib |
| 16 | + # mv all the platform-specific jars to target/ |
| 17 | + - aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/jar $CODEBUILD_SRC_DIR/aws-crt-java/target/ |
| 18 | + # cp all the shared libs to cmake-build/lib/ |
| 19 | + - aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/lib $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/lib |
| 20 | + # log the downloaded files |
| 21 | + - ls -alR $CODEBUILD_SRC_DIR/aws-crt-java/target |
| 22 | + # install settings.xml to ~/.m2/settings.xml |
| 23 | + - mkdir -p $HOME/.m2 |
| 24 | + - aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.token.xml $HOME/.m2/settings.xml |
| 25 | + # import gpg key |
| 26 | + - aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc |
| 27 | + # for https://github.com/keybase/keybase-issues/issues/2798 |
| 28 | + - export GPG_TTY=$(tty) |
| 29 | + - gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc |
| 30 | + # refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html |
| 31 | + - export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id aws-sdk-common-runtime.key.asc/password --region us-east-1 | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') |
| 32 | + - export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g') |
| 33 | + - export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f3 -d":" | sed -e 's/[\\\"\}]//g') |
| 34 | + # Use the username and password from secret manager to update the settings |
| 35 | + - sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml |
| 36 | + - sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml |
| 37 | + |
| 38 | + build: |
| 39 | + commands: |
| 40 | + # --- DEPLOY SNAPSHOT --- |
| 41 | + - cd $CODEBUILD_SRC_DIR/aws-crt-java |
| 42 | + # update the version to match the git tag, make a snapshot version we can test |
| 43 | + - export DEPLOY_VERSION=${PKG_VERSION}-SNAPSHOT |
| 44 | + - mvn -B versions:set -DnewVersion=${DEPLOY_VERSION} |
| 45 | + # do a full build/deploy, but skip shared libs and tests, since the shared libs were artifacts above |
| 46 | + - mvn -B deploy -Prelease -Dshared-lib.skip=true -Dmaven.test.skip=true |
| 47 | + |
| 48 | + post_build: |
| 49 | + commands: |
| 50 | + # --- TEST SNAPSHOT --- |
| 51 | + - mvn -B dependency:get -DrepoUrl=https://central.sonatype.com/repository/maven-snapshots/ -Dartifact=software.amazon.awssdk.crt:aws-crt:${DEPLOY_VERSION} -Dtransitive=false |
| 52 | + |
| 53 | +cache: |
| 54 | + paths: |
| 55 | + - "/root/.m2/**/*" |
0 commit comments