xref: /aosp_15_r20/external/aws-crt-java/codebuild/cd/deploy-snapshot.yml (revision 3c7ae9de214676c52d19f01067dc1a404272dc11)
1version: 0.2
2#this buildspec assumes the aws-common-runtime/ubuntu-16.04 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
5phases:
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-11-jdk-headless maven wget unzip -y -f
11      # install android sdk
12      - wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
13      - export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
14      - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
15      - unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
16      # This weird path needed for cmd tool to work
17      - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
18      # install android build tools
19      - echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-30" "ndk;21.4.7075529"
20
21  pre_build:
22    commands:
23      - cd $CODEBUILD_SRC_DIR/aws-crt-java
24      - export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
25      - echo $PKG_VERSION
26      - mkdir -p target/cmake-build/lib
27      # mv all the platform-specific jars to target/
28      - aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/jar $CODEBUILD_SRC_DIR/aws-crt-java/target/
29      - mv $CODEBUILD_SRC_DIR_linux_x64/dist/aws-crt-1.0.0-SNAPSHOT-linux-x86_64.jar $CODEBUILD_SRC_DIR/aws-crt-java/target/
30      - mv $CODEBUILD_SRC_DIR_linux_x86/dist/aws-crt-1.0.0-SNAPSHOT-linux-x86_32.jar $CODEBUILD_SRC_DIR/aws-crt-java/target/
31      # cp all the shared libs to cmake-build
32      - aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/lib $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/lib
33      - cp -rv $CODEBUILD_SRC_DIR_linux_x64/dist/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
34      - cp -rv $CODEBUILD_SRC_DIR_linux_x86/dist/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
35      - ls -alR $CODEBUILD_SRC_DIR/aws-crt-java/target
36      # install settings.xml to ~/.m2/settings.xml
37      - mkdir -p $HOME/.m2
38      - aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.xml $HOME/.m2/settings.xml
39      # import gpg key
40      - aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
41      - gpg --import /tmp/aws-sdk-common-runtime.key.asc
42      - 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')
43      - export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/Password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
44      # Use the password from secret manager to update the settings
45      - sed -i 's/password-to-replace/'"$ST_PASSWORD"'/g' $HOME/.m2/settings.xml
46  build:
47    commands:
48      - cd $CODEBUILD_SRC_DIR/aws-crt-java
49      # update the version to match the git tag, make a snapshot version we can test
50      - export DEPLOY_VERSION=${PKG_VERSION}-SNAPSHOT
51      - mvn -B versions:set -DnewVersion=${DEPLOY_VERSION}
52      # do a full build/deploy, but skip shared libs and tests, since the shared libs were artifacts above
53      - mvn -B deploy -Prelease -Dshared-lib.skip=true -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE
54      - bash ./codebuild/cd/deploy-platform-specific-jars.sh
55      # update the version to match the git tag, make a staging release which we will release once snapshot testing passes
56      - export DEPLOY_VERSION=${PKG_VERSION}
57      - mvn -B versions:set -DnewVersion=${DEPLOY_VERSION}
58      - mvn -B deploy -Prelease -Dshared-lib.skip=true -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE | tee /tmp/deploy.log
59      - export STAGING_REPO_ID=$(cat /tmp/deploy.log | grep "Created staging repository with ID" | cut -d\" -f2 | tee /tmp/repositoryId.txt)
60      # upload the platform specific jars to staging repo and close the staging repo.
61      - bash ./codebuild/cd/deploy-platform-specific-jars.sh
62      - mvn nexus-staging:close -Prelease -DstagingRepositoryId=$STAGING_REPO_ID
63      # deploy android
64      - ./codebuild/cd/deploy-snapshot-android.sh
65  post_build:
66    commands:
67
68artifacts:
69  discard-paths: yes
70  files:
71    - $CODEBUILD_SRC_DIR/aws-crt-java/target/aws-crt-*.jar
72    - $CODEBUILD_SRC_DIR/aws-crt-java/target/aws-crt-*.asc
73    - /tmp/repositoryId.txt
74    - /tmp/android_repositoryId.txt
75
76cache:
77  paths:
78    - "/root/.m2/**/*"
79