Skip to content

Commit 8a0fb88

Browse files
committed
split android deployment script
1 parent 030aa34 commit 8a0fb88

File tree

2 files changed

+66
-14
lines changed

2 files changed

+66
-14
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Assumes are running using the Ubuntu Codebuild standard image
2+
# Makes the full release deployment.
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+
#
6+
# NOTE: This script assumes that the AWS CLI-V2 is pre-installed!
7+
# - AWS CLI-V2 is a requirement to run this script.
8+
9+
version: 0.2
10+
phases:
11+
install:
12+
commands:
13+
- sudo add-apt-repository ppa:openjdk-r/ppa
14+
- sudo apt-get update -y
15+
# Android requires 11 for gradle
16+
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
17+
# install android sdk
18+
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
19+
- export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
20+
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
21+
- unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
22+
# This weird path needed for cmd tool to work
23+
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
24+
# install android build tools
25+
- echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-30" "ndk;21.4.7075529"
26+
- echo "\nBuild version data:"
27+
- echo "\nJava Version:"; java -version
28+
- echo "\nMaven Version:"; mvn --version
29+
- echo "\n"
30+
31+
pre_build:
32+
commands:
33+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
34+
- export PKG_VERSION=$(cat $CODEBUILD_SRC_DIR/VERSION)
35+
- echo PKG_VERSION=$PKG_VERSION
36+
37+
# install settings.xml to ~/.m2/settings.xml
38+
- mkdir -p $HOME/.m2
39+
- export CD_SETTINGS=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-settings/token --query "SecretString" | cut -f2 -d\")
40+
- echo $CD_SETTINGS > $HOME/.m2/settings.xml
41+
- 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')
42+
- 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')
43+
# Use the username and password from secret manager to update the settings
44+
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
45+
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
46+
47+
# import gpg key
48+
- export CD_KEY=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-key --query "SecretString" | cut -f2 -d\")
49+
- echo $CD_KEY > /tmp/aws-sdk-common-runtime.key.asc
50+
# for https://github.com/keybase/keybase-issues/issues/2798
51+
- export GPG_TTY=$(tty)
52+
53+
- gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc
54+
# refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html
55+
- export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
56+
57+
build:
58+
commands:
59+
# Deploy android
60+
- export PROMOTE_RELEASE=true
61+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
62+
- ./codebuild/cd/deploy-android.sh
63+
64+
cache:
65+
paths:
66+
- "/root/.m2/**/*"

codebuild/cd/promote-release.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ phases:
1414
- sudo apt-get update -y
1515
# Android requires 11 for gradle
1616
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
17-
# install android sdk
18-
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
19-
- export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
20-
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
21-
- unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
22-
# This weird path needed for cmd tool to work
23-
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
24-
# install android build tools
25-
- echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-30" "ndk;21.4.7075529"
2617
- echo "\nBuild version data:"
2718
- echo "\nJava Version:"; java -version
2819
- echo "\nMaven Version:"; mvn --version
@@ -59,11 +50,6 @@ phases:
5950
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
6051
# Trigger the release of the last staged package in the staging repository
6152
- mvn deploy -DskipTests
62-
63-
# Deploy android
64-
- export PROMOTE_RELEASE=true
65-
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
66-
- ./codebuild/cd/deploy-android.sh
6753

6854
cache:
6955
paths:

0 commit comments

Comments
 (0)