|
| 1 | +# Android CircleCI 2.0 configuration file |
| 2 | +# |
| 3 | +version: 2.1 |
| 4 | +commands: |
| 5 | + configure_aws: |
| 6 | + description: >- |
| 7 | + install aws cli and configure android aws release profile |
| 8 | + steps: |
| 9 | + - run: |
| 10 | + name: install aws cli |
| 11 | + command: | |
| 12 | + sudo pip install awscli |
| 13 | + - run: |
| 14 | + name: configure aws profile |
| 15 | + command: | |
| 16 | + aws configure --profile android_sdk_release set region us-east-1 |
| 17 | + echo -e "[android_sdk_release]\naws_access_key_id=${AWS_ACCESS_KEY_ID_ANDROID}\naws_secret_access_key=${AWS_SECRET_ACCESS_KEY_ANDROID}\n" >> ~/.aws/credentials |
| 18 | +
|
| 19 | + set_enviroment_vairables: |
| 20 | + description: >- |
| 21 | + set environment variables |
| 22 | + steps: |
| 23 | + - run: |
| 24 | + name: set environment variables |
| 25 | + command: | |
| 26 | + sdkName=aws-android-sdk |
| 27 | + echo "export sdkName=$sdkName" >> $BASH_ENV |
| 28 | +
|
| 29 | + release_bucket=${RELEASE_BUCKET} |
| 30 | + echo "export release_bucket=$release_bucket" >> $BASH_ENV |
| 31 | +
|
| 32 | + sdkNameWithVersion="$sdkName-$release_version" |
| 33 | + echo "export sdkNameWithVersion=$sdkNameWithVersion" >> $BASH_ENV |
| 34 | +
|
| 35 | + release_tag=${CIRCLE_TAG} |
| 36 | + echo "export release_tag=$release_tag" >> $BASH_ENV |
| 37 | +
|
| 38 | + release_version=$(echo "$release_tag" | sed 's|.*v\([0-9\.]*\).*|\1|') |
| 39 | + echo "export release_version=$release_version" >> $BASH_ENV |
| 40 | +
|
| 41 | +jobs: |
| 42 | + build: |
| 43 | + working_directory: ~/code |
| 44 | + docker: |
| 45 | + - image: circleci/android:api-27-alpha |
| 46 | + environment: |
| 47 | + JVM_OPTS: -Xmx3200m |
| 48 | + steps: |
| 49 | + - checkout |
| 50 | + - run: |
| 51 | + name: build the whole project |
| 52 | + command: | |
| 53 | + echo "id=${android_distribution_id}" |
| 54 | + bash gradlew build -x test |
| 55 | +
|
| 56 | + buildforrelease: |
| 57 | + working_directory: ~/code |
| 58 | + docker: |
| 59 | + - image: circleci/android:api-27-alpha |
| 60 | + environment: |
| 61 | + JVM_OPTS: -Xmx3200m |
| 62 | + steps: |
| 63 | + - checkout |
| 64 | + - run: |
| 65 | + name: build the whole project |
| 66 | + command: bash gradlew build -x test |
| 67 | + - run: |
| 68 | + name: copy libs |
| 69 | + command: | |
| 70 | + rootfolder=$(pwd) |
| 71 | + python3 CircleciScripts/copy_libs.py "$(pwd)" "$(pwd)/lib" |
| 72 | + - save_cache: |
| 73 | + key: Libs-{{ .Revision }} |
| 74 | + paths: |
| 75 | + - lib |
| 76 | + |
| 77 | + unittest: |
| 78 | + working_directory: ~/code |
| 79 | + docker: |
| 80 | + - image: circleci/android:api-27-alpha |
| 81 | + environment: |
| 82 | + JVM_OPTS: -Xmx1024m |
| 83 | + steps: |
| 84 | + - checkout |
| 85 | + - set_enviroment_vairables |
| 86 | + - run: |
| 87 | + name: run unit tests |
| 88 | + command: | |
| 89 | + python3 CircleciScripts/run_unittest.py "~/test_results" "$(pwd)" |
| 90 | + - run: |
| 91 | + name : check unit test result |
| 92 | + command : | |
| 93 | + echo "testresult=$testresult" |
| 94 | + if [ "$testresult" == "0" ] |
| 95 | + then |
| 96 | + echo "test succeed!" |
| 97 | + else |
| 98 | + echo "There are test failures" |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | + - store_artifacts: |
| 102 | + path: "~/test_results" |
| 103 | + |
| 104 | + release_tag: |
| 105 | + working_directory: ~/code |
| 106 | + docker: |
| 107 | + - image: circleci/golang:1.11 |
| 108 | + steps: |
| 109 | + - checkout |
| 110 | + - set_enviroment_vairables |
| 111 | + - run: |
| 112 | + name: install github-release |
| 113 | + command: go get github.com/aktau/github-release |
| 114 | + - run: |
| 115 | + name: release the tag |
| 116 | + command: | |
| 117 | + tagdescription=$(sed -n "/## \[Release $release_version\]/,/## \[Release [0-9]*\.[0-9]*\.[0-9]\]/p" CHANGELOG.md | sed '1d' | sed '$d') |
| 118 | + echo "$tagdescription" | github-release release -s ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t $release_tag --name "$tagname" -d - |
| 119 | +
|
| 120 | + release_javadoc: |
| 121 | + docker: |
| 122 | + - image: circleci/android:api-27-alpha |
| 123 | + environment: |
| 124 | + JVM_OPTS: -Xmx3200m |
| 125 | + steps: |
| 126 | + - checkout |
| 127 | + - set_enviroment_vairables |
| 128 | + - run: |
| 129 | + name: install python3-pip |
| 130 | + command: | |
| 131 | + sudo apt-get update |
| 132 | + sudo apt-get -y install python3-pip |
| 133 | + - run: |
| 134 | + name: install json parser |
| 135 | + command: sudo pip3 install demjson |
| 136 | + - run: |
| 137 | + name: install aws cli |
| 138 | + command: | |
| 139 | + sudo pip install awscli |
| 140 | + - run: |
| 141 | + name: download third party libararies |
| 142 | + command: | |
| 143 | + aws s3 cp s3://android-circleci-payload/third-party/third-party.zip third-party.zip |
| 144 | + unzip third-party.zip |
| 145 | + cp "$ANDROID_HOME/platforms/android-27/android.jar" third-party/android.jar |
| 146 | + - run: |
| 147 | + name: generate documents |
| 148 | + command: | |
| 149 | + currentfolder=$(pwd) |
| 150 | + python3 CircleciScripts/generate_javadoc.py CircleciScripts/ReleaseConfiguration.json "$currentfolder" build/javadoc third-party "$release_version" |
| 151 | + - run: |
| 152 | + name: check out gh-pages and preserve old document |
| 153 | + command: | |
| 154 | + git config --local user.name "${GITHUB_USER}" |
| 155 | + git checkout gh-pages |
| 156 | + git checkout master CircleciScripts/preserve_olddocument.sh |
| 157 | + bash CircleciScripts/preserve_olddocument.sh |
| 158 | + - run: |
| 159 | + name: copy new document |
| 160 | + command: | |
| 161 | + cp -R build/javadoc/* docs/reference/ |
| 162 | + - run: |
| 163 | + name: check in documents |
| 164 | + command: | |
| 165 | + git add docs/reference |
| 166 | + git rm --cached CircleciScripts/preserve_olddocument.sh |
| 167 | + git commit -m "AWS SDK for Android $release_version" |
| 168 | + git push -q https://${GITHUB_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git |
| 169 | + - save_cache: |
| 170 | + key: API-Reference-{{ .Revision }} |
| 171 | + paths: |
| 172 | + - docs/reference/ |
| 173 | + |
| 174 | + tag_doc: |
| 175 | + docker: |
| 176 | + - image: circleci/android:api-27-alpha |
| 177 | + environment: |
| 178 | + JVM_OPTS: -Xmx3200m |
| 179 | + steps: |
| 180 | + - checkout |
| 181 | + - set_enviroment_vairables |
| 182 | + - run: |
| 183 | + name: Add documentation tags to gh-pages |
| 184 | + command: | |
| 185 | + git config --local user.name "${GITHUB_USER}" |
| 186 | + git checkout gh-pages |
| 187 | + git tag -a "docs_v$release_version" -m "Add documentation tags to version $release_version" |
| 188 | + git push --tags -q https://${GITHUB_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git |
| 189 | +
|
| 190 | + release_maven: |
| 191 | + macos: |
| 192 | + xcode: "10.1.0" #xocde version number does not matter here, we just need a macos image |
| 193 | + steps: |
| 194 | + - checkout |
| 195 | + - configure_aws |
| 196 | + - set_enviroment_vairables |
| 197 | + - run: |
| 198 | + name: install android sdk tools |
| 199 | + command: | |
| 200 | + HOMEBREW_LOGS=~/homebrew-logs |
| 201 | + HOMEBREW_TEMP=~/homebrew-temp |
| 202 | + brew update |
| 203 | + brew doctor |
| 204 | + brew tap caskroom/cask |
| 205 | + brew cask install android-sdk |
| 206 | + - run: |
| 207 | + name: install android build tools |
| 208 | + command: | |
| 209 | + sudo yes | /usr/local/bin/sdkmanager "platforms;android-21" "platforms;android-27" "build-tools;27.0.1" "extras;google;m2repository" "extras;android;m2repository" |
| 210 | + /usr/local/bin/sdkmanager --update |
| 211 | + - run: |
| 212 | + name: Instal gpg |
| 213 | + command: | |
| 214 | + brew install gnupg |
| 215 | + - run: |
| 216 | + name: install maven |
| 217 | + command: | |
| 218 | + brew install maven |
| 219 | + - run: |
| 220 | + name: Set environment |
| 221 | + command: | |
| 222 | + echo ~ |
| 223 | + ls /usr/local/share/android-sdk |
| 224 | + ANDROID_HOME="/usr/local/share/android-sdk" |
| 225 | + echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV |
| 226 | + echo "Home: ${HOME}" |
| 227 | + echo "JAVA_HOME: $JAVA_HOME" |
| 228 | + echo "ANDROID_HOME: $ANDROID_HOME" |
| 229 | + echo "PATH: $PATH" |
| 230 | + echo 'export ANDROID_PLATFORM="27"' >> $BASH_ENV |
| 231 | + echo 'export ANDROID_BUILDTOOL_VERSION="27.0.1"' >> $BASH_ENV |
| 232 | + - run: |
| 233 | + name: download gpghome |
| 234 | + command: | |
| 235 | + aws s3 cp s3://android-circleci-payload/gpghome/gpghome.zip gpghome.zip |
| 236 | + unzip -a gpghome.zip |
| 237 | + - run: |
| 238 | + name: publish to maven |
| 239 | + command: | |
| 240 | + echo "${HOME}" |
| 241 | + echo "$JAVA_HOME" |
| 242 | + echo "$ANDROID_HOME" |
| 243 | + echo "$M2_HOME" |
| 244 | + bash CircleciScripts/maven_release.sh |
| 245 | +
|
| 246 | + release_s3: |
| 247 | + docker: |
| 248 | + - image: circleci/android:api-27-alpha |
| 249 | + environment: |
| 250 | + JVM_OPTS: -Xmx1024m |
| 251 | + steps: |
| 252 | + - checkout |
| 253 | + - configure_aws |
| 254 | + - set_enviroment_vairables |
| 255 | + - run: |
| 256 | + name: copy sdk resource |
| 257 | + command: | |
| 258 | + mkdir -p "$sdkNameWithVersion" |
| 259 | + python3 CircleciScripts/copy_resourcefiles.py "$(pwd)" "$(pwd)/$sdkNameWithVersion" |
| 260 | + - restore_cache: |
| 261 | + key: Libs-{{ .Revision }} |
| 262 | + - run: |
| 263 | + name: copy libs |
| 264 | + command: | |
| 265 | + mkdir -p "$sdkNameWithVersion/lib" |
| 266 | + cp -R /home/circleci/code/lib/* "$sdkNameWithVersion/lib" |
| 267 | + - restore_cache: |
| 268 | + key: API-Reference-{{ .Revision }} |
| 269 | + - run: |
| 270 | + name: copy documents |
| 271 | + command: | |
| 272 | + mkdir -p "$sdkNameWithVersion/documentation/javadoc" |
| 273 | + cp -R docs/reference/* "$sdkNameWithVersion/documentation/javadoc" |
| 274 | + - run: |
| 275 | + name: copy third party |
| 276 | + command: | |
| 277 | + aws s3 cp s3://android-circleci-payload/third-party/third-party.zip third-party.zip |
| 278 | + unzip third-party.zip |
| 279 | + mv third-party "$sdkNameWithVersion/third-party" |
| 280 | + - run: |
| 281 | + name: zip sdk folder |
| 282 | + command: | |
| 283 | + zip -r "$sdkNameWithVersion.zip" "$sdkNameWithVersion" |
| 284 | + - run: |
| 285 | + name: upload to s3 |
| 286 | + command: | |
| 287 | + aws s3 cp "$sdkNameWithVersion.zip" "s3://$release_bucket/$sdkNameWithVersion.zip" --profile android_sdk_release |
| 288 | + aws s3 cp "$sdkNameWithVersion.zip" "s3://$release_bucket/latest/$sdkName.zip" --profile android_sdk_release |
| 289 | + - run: |
| 290 | + name: invalidate cloudfront |
| 291 | + command: | |
| 292 | + python3 CircleciScripts/cloudfront_invalidate.py android_sdk_release "${android_distribution_id}" "$sdkName.zip" |
| 293 | +
|
| 294 | +workflows: |
| 295 | + version: 2 |
| 296 | + |
| 297 | + build_test: |
| 298 | + jobs: |
| 299 | + - build |
| 300 | + - unittest: |
| 301 | + requires: |
| 302 | + - build |
| 303 | + release_sdk: |
| 304 | + jobs: |
| 305 | + - buildforrelease: |
| 306 | + filters: |
| 307 | + branches: |
| 308 | + ignore: /.*/ |
| 309 | + tags: |
| 310 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 311 | + - unittest: |
| 312 | + requires: |
| 313 | + - buildforrelease |
| 314 | + filters: |
| 315 | + branches: |
| 316 | + ignore: /.*/ |
| 317 | + tags: |
| 318 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 319 | + - release_maven: |
| 320 | + requires: |
| 321 | + - unittest |
| 322 | + filters: |
| 323 | + branches: |
| 324 | + ignore: /.*/ |
| 325 | + tags: |
| 326 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 327 | + |
| 328 | + - release_javadoc: |
| 329 | + requires: |
| 330 | + - unittest |
| 331 | + filters: |
| 332 | + branches: |
| 333 | + ignore: /.*/ |
| 334 | + tags: |
| 335 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 336 | + |
| 337 | + - tag_doc: |
| 338 | + requires: |
| 339 | + - release_javadoc |
| 340 | + filters: |
| 341 | + branches: |
| 342 | + ignore: /.*/ |
| 343 | + tags: |
| 344 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 345 | + |
| 346 | + - release_s3: |
| 347 | + requires: |
| 348 | + - release_javadoc |
| 349 | + - release_maven |
| 350 | + filters: |
| 351 | + branches: |
| 352 | + ignore: /.*/ |
| 353 | + tags: |
| 354 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
| 355 | + |
| 356 | + - release_tag: |
| 357 | + requires: |
| 358 | + - release_s3 |
| 359 | + filters: |
| 360 | + branches: |
| 361 | + ignore: /.*/ |
| 362 | + tags: |
| 363 | + only: /^release_v[0-9]+.[0-9]+.[0-9]+$/ |
0 commit comments