diff --git a/.cirrus.yml b/.cirrus.yml index 3a0c423..176305e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,23 @@ docker_builder: - name: Build + name: Build images with JDK $JDK_VERSION only_if: $CIRRUS_BRANCH != $CIRRUS_DEFAULT_BRANCH + env: + # Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800 + matrix: + - ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+ + JDK_VERSION: 8 + - ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+ + JDK_VERSION: 11 + - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+ + JDK_VERSION: 17 + - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+ + JDK_VERSION: 21 + export_env_vars_script: + - echo "ANDROID_CLT_VERSION=$ANDROID_CLT_VERSION" >> $CIRRUS_ENV + - echo "JDK_VERSION=$JDK_VERSION" >> $CIRRUS_ENV + info_script: + - docker --version + - echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_VERSION" version_script: docker --version setup_script: - docker buildx create --name multibuilder @@ -8,23 +25,42 @@ docker_builder: - docker buildx inspect --bootstrap build_tools_script: | docker buildx build --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/cirruslabs/android-sdk:tools \ + --build-arg android_clt_version=$ANDROID_CLT_VERSION \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:tools-jdk${JDK_VERSION} \ sdk/tools build_sdk_script: | docker buildx build --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/cirruslabs/android-sdk:34 \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:34-jdk${JDK_VERSION} \ sdk/34 build_ndk_script: | docker buildx build --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/cirruslabs/android-sdk:34-ndk \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:34-ndk-jdk${JDK_VERSION} \ sdk/34-ndk docker_builder: - name: Push + name: Build and push images with JDK $JDK_VERSION only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH env: + # Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800 + matrix: + - ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+ + JDK_VERSION: 8 + - ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+ + JDK_VERSION: 11 + - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+ + JDK_VERSION: 17 + - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+ + JDK_VERSION: 21 GITHUB_TOKEN: ENCRYPTED[!82ed873afdf627284305afef4958c85a8f73127b09978a9786ac521559630ea6c9a5ab6e7f8315abf9ead09b6eff6eae!] - version_script: docker --version + export_env_vars_script: + - echo "ANDROID_CLT_VERSION=$ANDROID_CLT_VERSION" >> $CIRRUS_ENV + - echo "JDK_VERSION=$JDK_VERSION" >> $CIRRUS_ENV + info_script: + - docker --version + - echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_VERSION" login_script: - echo $GITHUB_TOKEN | docker login ghcr.io -u fkorotkov --password-stdin setup_script: @@ -33,17 +69,43 @@ docker_builder: - docker buildx inspect --bootstrap build_tools_script: | docker buildx build --platform linux/amd64,linux/arm64 --push \ - --tag ghcr.io/cirruslabs/android-sdk:tools \ + --build-arg android_clt_version=$ANDROID_CLT_VERSION \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:tools-jdk${JDK_VERSION} \ sdk/tools build_sdk_script: | docker buildx build --platform linux/amd64,linux/arm64 --push \ - --tag ghcr.io/cirruslabs/android-sdk:34 \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:34-jdk${JDK_VERSION} \ sdk/34 build_ndk_script: | docker buildx build --platform linux/amd64,linux/arm64 --push \ - --tag ghcr.io/cirruslabs/android-sdk:34-ndk \ + --build-arg jdk_version=$JDK_VERSION \ + --tag ghcr.io/cirruslabs/android-sdk:34-ndk-jdk${JDK_VERSION} \ sdk/34-ndk +docker_builder: + name: Push tags of default images + only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH + depends_on: + - Build and push images with JDK 17 + env: + GITHUB_TOKEN: ENCRYPTED[!82ed873afdf627284305afef4958c85a8f73127b09978a9786ac521559630ea6c9a5ab6e7f8315abf9ead09b6eff6eae!] + login_script: + - echo $GITHUB_TOKEN | docker login ghcr.io -u fkorotkov --password-stdin + pull_images_script: | + docker pull ghcr.io/cirruslabs/android-sdk:tools-jdk17 + docker pull ghcr.io/cirruslabs/android-sdk:34-jdk17 + docker pull ghcr.io/cirruslabs/android-sdk:34-ndk-jdk17 + create_tags_script: | + docker tag ghcr.io/cirruslabs/android-sdk:tools-jdk17 ghcr.io/cirruslabs/android-sdk:tools + docker tag ghcr.io/cirruslabs/android-sdk:34-jdk17 ghcr.io/cirruslabs/android-sdk:tools + docker tag ghcr.io/cirruslabs/android-sdk:34-ndk-jdk17 ghcr.io/cirruslabs/android-sdk:tools + push_tags_script: | + docker push ghcr.io/cirruslabs/android-sdk:tools + docker push ghcr.io/cirruslabs/android-sdk:34 + docker push ghcr.io/cirruslabs/android-sdk:34-ndk + task: name: Smoke Test container: @@ -53,6 +115,8 @@ task: kvm: "true" env: EMULATOR_IMAGE: system-images;android-34;aosp_atd;x86_64 + ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+ + JDK_VERSION: 17 setup_script: | sdkmanager --install "platforms;android-34" sdkmanager --install "build-tools;34.0.0" @@ -81,4 +145,3 @@ task: cd testing-samples cd runner/AndroidTestOrchestratorSample ./gradlew :app:connectedAndroidTest - diff --git a/sdk/34-ndk/Dockerfile b/sdk/34-ndk/Dockerfile index 11515fc..72ff847 100644 --- a/sdk/34-ndk/Dockerfile +++ b/sdk/34-ndk/Dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/cirruslabs/android-sdk:34 +ARG jdk_version=17 + +FROM ghcr.io/cirruslabs/android-sdk:34-jdk${jdk_version} # https://developer.android.com/ndk/downloads ENV ANDROID_NDK_VERSION 26.2.11394342 diff --git a/sdk/34/Dockerfile b/sdk/34/Dockerfile index 9cfdcce..4d53739 100644 --- a/sdk/34/Dockerfile +++ b/sdk/34/Dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/cirruslabs/android-sdk:tools +ARG jdk_version=17 + +FROM ghcr.io/cirruslabs/android-sdk:tools-jdk${jdk_version} # https://developer.android.com/studio/releases/build-tools ENV ANDROID_PLATFORM_VERSION 34 diff --git a/sdk/tools/Dockerfile b/sdk/tools/Dockerfile index 28f6899..70cc7e3 100644 --- a/sdk/tools/Dockerfile +++ b/sdk/tools/Dockerfile @@ -13,13 +13,18 @@ ENV ANDROID_SDK_ROOT=$ANDROID_HOME \ PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator # comes from https://developer.android.com/studio/#command-tools -ENV ANDROID_SDK_TOOLS_VERSION 10406996 +# see also https://stackoverflow.com/a/78890086/7009800 +ARG android_clt_version=11479570 +ARG jdk_version=17 + +ENV ANDROID_SDK_TOOLS_VERSION=${android_clt_version} +ENV JDK_PACKAGE="openjdk-${jdk_version}-jdk" RUN set -o xtrace \ && cd /opt \ && apt-get update \ && apt-get install -y jq \ - && apt-get install -y openjdk-17-jdk \ + && apt-get install -y ${JDK_PACKAGE} \ && apt-get install -y sudo wget zip unzip git openssh-client curl bc software-properties-common build-essential ruby-full ruby-bundler libstdc++6 libpulse0 libglu1-mesa locales lcov libsqlite3-dev --no-install-recommends \ # for x86 emulators && apt-get install -y libxtst6 libnss3-dev libnspr4 libxss1 libasound2t64 libatk-bridge2.0-0 libgtk-3-0 libgdk-pixbuf2.0-0 \ @@ -45,4 +50,4 @@ RUN set -o xtrace \ && git config --global user.name "Cirrus CI" # emulator is not available on linux/arm64 (https://issuetracker.google.com/issues/227219818) -RUN if [ $(uname -m) == "x86_64" ]; then sdkmanager emulator ; fi +RUN if [ "$(uname -m)" = "x86_64" ]; then sdkmanager emulator ; fi