From b4aed1309c78a3e0c5dced2542eb79fc5d927856 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 27 Jun 2022 09:53:16 -0500 Subject: [PATCH] ci: Move default versions from install-android-sdk to the config.yml --- .gitlab-ci/ci-scripts.mk | 1 + .gitlab-ci/config.yml | 7 ++++ .gitlab-ci/install-android-sdk.sh | 8 +++++ .gitlab-ci/install-android-sdk.sh.jinja | 47 +++++++++++++++++++++++++ build.gradle | 3 ++ 5 files changed, 66 insertions(+) create mode 100755 .gitlab-ci/install-android-sdk.sh.jinja diff --git a/.gitlab-ci/ci-scripts.mk b/.gitlab-ci/ci-scripts.mk index 01e53560d..95a77a266 100644 --- a/.gitlab-ci/ci-scripts.mk +++ b/.gitlab-ci/ci-scripts.mk @@ -8,6 +8,7 @@ FILES_IN_SUBDIR := \ .gitlab-ci/distributions \ .gitlab-ci/reprepro.sh \ + .gitlab-ci/install-android-sdk.sh \ CONFIG_FILE := .gitlab-ci/config.yml OUTPUTS := .gitlab-ci.yml \ diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml index 46749b46b..f30b817f9 100644 --- a/.gitlab-ci/config.yml +++ b/.gitlab-ci/config.yml @@ -116,6 +116,13 @@ distributions: repo_suffix: ndk script: android_container_prep.sh tag: "2022-06-27.0" + # This must match ext.sharedTargetSdk in build.gradle + android_compile_sdk: 31 + # This must match buildscript.ext.buildToolsVersion in build.gradle + android_build_tools: 31.0.0 + # look up on https://developer.android.com/studio/index.html#downloads when updating other versions + android_cli_tools: 8512546 + packages: git: wget: diff --git a/.gitlab-ci/install-android-sdk.sh b/.gitlab-ci/install-android-sdk.sh index 2c61bbc56..dccada250 100755 --- a/.gitlab-ci/install-android-sdk.sh +++ b/.gitlab-ci/install-android-sdk.sh @@ -2,6 +2,13 @@ # Copyright 2022, Collabora, Ltd. and the Monado contributors # SPDX-License-Identifier: BSL-1.0 +## +####################################################### +# GENERATED - DO NOT EDIT # +# see .gitlab-ci/install-android-sdk.sh.jinja instead # +####################################################### +## + # Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ set -eo pipefail @@ -32,3 +39,4 @@ echo y | $SDKMANAGER "build-tools;${ANDROID_BUILD_TOOLS}" >> /dev/null set +o pipefail yes | $SDKMANAGER --licenses set -o pipefail + diff --git a/.gitlab-ci/install-android-sdk.sh.jinja b/.gitlab-ci/install-android-sdk.sh.jinja new file mode 100755 index 000000000..3009712ee --- /dev/null +++ b/.gitlab-ci/install-android-sdk.sh.jinja @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Copyright 2022, Collabora, Ltd. and the Monado contributors +# SPDX-License-Identifier: BSL-1.0 + +#{# ignore the warning, this is actually the template to edit. #}# +####################################################### +# GENERATED - DO NOT EDIT # +# see .gitlab-ci/install-android-sdk.sh.jinja instead # +####################################################### +#{# +Please run the following after editing: + make -f .gitlab-ci/ci-scripts.mk +#}# + +# Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ +{% for distro in distributions -%} {%- for image in distro.images if "android_compile_sdk" in image %} + +set -eo pipefail +VERSION={{image.android_cli_tools}} +ROOT=${ROOT:-/opt/android-sdk} +ANDROID_COMPILE_SDK=${ANDROID_COMPILE_SDK:-{{image.android_compile_sdk}}} +ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-{{image.android_build_tools}}} + +mkdir -p "$ROOT" +FN=commandlinetools-linux-${VERSION}_latest.zip +wget https://dl.google.com/android/repository/$FN +unzip $FN -d "$ROOT/extract" +mkdir -p "$ROOT/cmdline-tools" +mv "$ROOT/extract/cmdline-tools/" "$ROOT/cmdline-tools/latest/" +mv "$ROOT/extract/" "$ROOT/cmdline-tools/" + +SDKMANAGER=$ROOT/cmdline-tools/latest/bin/sdkmanager + +echo "Installing the Android compile SDK platform android-${ANDROID_COMPILE_SDK}" +echo y | $SDKMANAGER "platforms;android-${ANDROID_COMPILE_SDK}" >> /dev/null + +echo "Installing the Android platform tools" +echo y | $SDKMANAGER "platform-tools" >> /dev/null + +echo "Installing the Android build tools ${ANDROID_BUILD_TOOLS}" +echo y | $SDKMANAGER "build-tools;${ANDROID_BUILD_TOOLS}" >> /dev/null + +set +o pipefail +yes | $SDKMANAGER --licenses +set -o pipefail + +{% endfor -%} {%- endfor %} diff --git a/build.gradle b/build.gradle index 44b907498..ccf4420fe 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,8 @@ buildscript { // This is the version to download if we can't find it locally. eigenFetchVersion = '3.4.0' + + // If you update this, must also update .gitlab-ci/config.yml buildToolsVersion = "31.0.0" } repositories { @@ -54,6 +56,7 @@ plugins { ext { ndk_version = '21.4.7075529' + // If you update this, must also update .gitlab-ci/config.yml sharedTargetSdk = 31 sharedMinSdk = 26