diff --git a/build_presubmit.sh b/build_presubmit_mobile.sh similarity index 94% rename from build_presubmit.sh rename to build_presubmit_mobile.sh index 0ae803af..87d4ab3a 100755 --- a/build_presubmit.sh +++ b/build_presubmit_mobile.sh @@ -98,9 +98,6 @@ echo "INFO: Cleaning the project..." echo "INFO: Building the Android production release bundle..." ./gradlew app:bundleRelease app:spdxSbomForRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true -echo "INFO: Building the Wear OS production release bundle..." -./gradlew wear:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true - # --- Artifact Collection --- echo "INFO: Preparing artifacts for Kokoro..." @@ -138,7 +135,4 @@ collect_artifacts "app/build/outputs/bundle/release" "app-release.aab" "app-rele echo "INFO: Copying SPDX SBOM..." cp app/build/spdx/release.spdx.json "${KOKORO_ARTIFACTS_DIR}/artifacts/app-release.spdx.json" -# Collect the Wear OS application artifacts -collect_artifacts "wear/build/outputs/bundle/release" "wear-release.aab" "wear-release-unsigned.aab" - exit 0 \ No newline at end of file diff --git a/build_presubmit_wear.sh b/build_presubmit_wear.sh new file mode 100755 index 00000000..80d56f61 --- /dev/null +++ b/build_presubmit_wear.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash +# +# Copyright 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# IGNORE this file, it's only used in the internal Google release process +# Fail on any error to ensure the script stops if a step fails. +set -e + +# --- Configuration --- +# Get the script's directory. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo DIR +# Define the Android SDK version you want to target. +ANDROID_SDK_VERSION="36" +ANDROID_BUILD_TOOLS_VERSION="36.0.0" + +# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). +# This system image is designed for headless, automated testing in CI environments +# and is more compatible with software rendering. It will be installed but may not +# be used by the new build command. +# 36 not available yet as per b/432143095 +EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64" + +# --- Environment Setup --- + +# Step 1: Check for essential command-line tools. +echo "INFO: Checking for prerequisites (wget, unzip, tar)..." +for cmd in wget unzip tar; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: Command '$cmd' not found. Please install it using your system's package manager (e.g., 'sudo apt-get install $cmd') and try again." + exit 1 + fi +done +echo "INFO: Prerequisites are installed." + + +# Step 2: Install and configure Java 17 system-wide. +echo "INFO: Setting up Java 17..." +# The build needs Java 17, set it as the default Java version. +sudo apt-get update +sudo apt-get install -y openjdk-17-jdk +sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java +java -version + +# Also clear JAVA_HOME variable so java -version is used instead +export JAVA_HOME= + +# Add the local SDK and emulator tools to the PATH for this session. +# The system-wide Java will already be in the PATH. +export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" +echo "INFO: Local tools added to PATH." + +# Now, accept licenses and install packages. +# It's best practice to accept licenses *after* the tools are in place. +echo "INFO: Accepting all pending SDK licenses..." +yes | sdkmanager --licenses + +echo "INFO: Installing Android SDK packages, including emulator and system image..." +# This single command will install/update all necessary packages. +sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" + +# Run license acceptance AGAIN after installing new packages. This is crucial. +echo "INFO: Accepting licenses for newly installed packages..." +yes | sdkmanager --licenses + +echo "Copying google-services.json" +cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app + +echo "Copying gradle.properties" +echo "" >> ${DIR}/gradle.properties # add a new line to the file +cat /tmpfs/src/git/androidify-prebuilts/gradle.properties >> ${DIR}/gradle.properties +ls + +# --- Build Process --- + +# This script assembles the release build of the Android application. +# Ensure gradlew is executable +chmod +x ./gradlew + +# Clean the project (optional, but good for a fresh release build) +echo "INFO: Cleaning the project..." +./gradlew clean -Pandroid.sdk.path=$ANDROID_HOME + +echo "INFO: Building the Wear OS production release bundle..." +./gradlew wear:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true + +# --- Artifact Collection --- +echo "INFO: Preparing artifacts for Kokoro..." + +# This function collects a specific AAB and its associated in-toto files. +# Arguments: +# $1: Source directory for the AAB (e.g., "app/build/outputs/bundle/release") +# $2: Source filename for the AAB (e.g., "app-release.aab") +# $3: Destination filename for the AAB (e.g., "app-release-unsigned.aab") +collect_artifacts() { + local aab_src_dir="$1" + local aab_file="$2" + local aab_dest_file="$3" + local aab_path="${aab_src_dir}/${aab_file}" + + # Check if the AAB exists + if [[ -f "$aab_path" ]]; then + # Create a directory within Kokoro's artifact collection area + local artifact_dest_dir="${KOKORO_ARTIFACTS_DIR}/artifacts" + mkdir -p "${artifact_dest_dir}" + + # Copy the AAB + cp "${aab_path}" "${artifact_dest_dir}/${aab_dest_file}" + echo "SUCCESS: AAB copied to ${artifact_dest_dir}" + + + else + echo "FAILURE: AAB not found at ${aab_path}" + exit 1 + fi +} + +# Collect the Wear OS application artifacts +collect_artifacts "wear/build/outputs/bundle/release" "wear-release.aab" "wear-release-unsigned.aab" + +exit 0 \ No newline at end of file diff --git a/build.sh b/build_release_mobile.sh similarity index 94% rename from build.sh rename to build_release_mobile.sh index ea8f29c8..c27a14af 100755 --- a/build.sh +++ b/build_release_mobile.sh @@ -96,9 +96,6 @@ echo "INFO: Cleaning the project..." echo "INFO: Building the Android production release bundle..." ./gradlew app:bundleRelease app:spdxSbomForRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true -echo "INFO: Building the Wear OS production release bundle..." -./gradlew wear:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true - # --- Artifact Collection --- echo "INFO: Preparing artifacts for Kokoro..." @@ -136,7 +133,4 @@ collect_artifacts "app/build/outputs/bundle/release" "app-release.aab" "app-rele echo "INFO: Copying SPDX SBOM..." cp app/build/spdx/release.spdx.json "${KOKORO_ARTIFACTS_DIR}/artifacts/app-release.spdx.json" -# Collect the Wear OS application artifacts -collect_artifacts "wear/build/outputs/bundle/release" "wear-release.aab" "wear-release-unsigned.aab" - exit 0 \ No newline at end of file diff --git a/build_release_wear.sh b/build_release_wear.sh new file mode 100755 index 00000000..8d747b78 --- /dev/null +++ b/build_release_wear.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash +# +# Copyright 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# IGNORE this file, it's only used in the internal Google release process +# Fail on any error to ensure the script stops if a step fails. +set -e + +# --- Configuration --- +# Get the script's directory. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Define the Android SDK version you want to target. +ANDROID_SDK_VERSION="36" +ANDROID_BUILD_TOOLS_VERSION="36.0.0" + +# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device). +# This system image is designed for headless, automated testing in CI environments +# and is more compatible with software rendering. It will be installed but may not +# be used by the new build command. +# 36 not available yet as per b/432143095 +EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64" + +# --- Environment Setup --- + +# Step 1: Check for essential command-line tools. +echo "INFO: Checking for prerequisites (wget, unzip, tar)..." +for cmd in wget unzip tar; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: Command '$cmd' not found. Please install it using your system's package manager (e.g., 'sudo apt-get install $cmd') and try again." + exit 1 + fi +done +echo "INFO: Prerequisites are installed." + + +# Step 2: Install and configure Java 17 system-wide. +echo "INFO: Setting up Java 17..." +# The build needs Java 17, set it as the default Java version. +sudo apt-get update +sudo apt-get install -y openjdk-17-jdk +sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java +java -version + +# Also clear JAVA_HOME variable so java -version is used instead +export JAVA_HOME= + +# Add the local SDK and emulator tools to the PATH for this session. +# The system-wide Java will already be in the PATH. +export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator" +echo "INFO: Local tools added to PATH." + +# Now, accept licenses and install packages. +# It's best practice to accept licenses *after* the tools are in place. +echo "INFO: Accepting all pending SDK licenses..." +yes | sdkmanager --licenses + +echo "INFO: Installing Android SDK packages, including emulator and system image..." +# This single command will install/update all necessary packages. +sdkmanager "platforms;android-${ANDROID_SDK_VERSION}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "${EMULATOR_IMAGE}" "emulator" + +# Run license acceptance AGAIN after installing new packages. This is crucial. +echo "INFO: Accepting licenses for newly installed packages..." +yes | sdkmanager --licenses + +echo "Copying google-services.json" +cp /tmpfs/src/git/androidify-prebuilts/google-services.json ${DIR}/app + +echo "Copying gradle.properties" +echo "" >> ${DIR}/gradle.properties # add a new line to the file +cat /tmpfs/src/git/androidify-prebuilts/gradle.properties >> ${DIR}/gradle.properties + +# --- Build Process --- + +# This script assembles the release build of the Android application. +# Ensure gradlew is executable +chmod +x ./gradlew + +# Clean the project (optional, but good for a fresh release build) +echo "INFO: Cleaning the project..." +./gradlew clean -Pandroid.sdk.path=$ANDROID_HOME + +echo "INFO: Building the Wear OS production release bundle..." +./gradlew wear:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true + +# --- Artifact Collection --- +echo "INFO: Preparing artifacts for Kokoro..." + +# This function collects a specific AAB and its associated in-toto files. +# Arguments: +# $1: Source directory for the AAB (e.g., "app/build/outputs/bundle/release") +# $2: Source filename for the AAB (e.g., "app-release.aab") +# $3: Destination filename for the AAB (e.g., "app-release-unsigned.aab") +collect_artifacts() { + local aab_src_dir="$1" + local aab_file="$2" + local aab_dest_file="$3" + local aab_path="${aab_src_dir}/${aab_file}" + + # Check if the AAB exists + if [[ -f "$aab_path" ]]; then + # Create a directory within Kokoro's artifact collection area + local artifact_dest_dir="${KOKORO_ARTIFACTS_DIR}/artifacts" + mkdir -p "${artifact_dest_dir}" + + # Copy the AAB + cp "${aab_path}" "${artifact_dest_dir}/${aab_dest_file}" + echo "SUCCESS: AAB copied to ${artifact_dest_dir}" + + else + echo "FAILURE: AAB not found at ${aab_path}" + exit 1 + fi +} + +# Collect the Wear OS application artifacts +collect_artifacts "wear/build/outputs/bundle/release" "wear-release.aab" "wear-release-unsigned.aab" + +exit 0 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8ece1e63..fa232077 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # build appVersionCode = "7" -appVersionName = "1.1.5" +appVersionName = "1.2.0" agp = "8.11.1" bcpkixJdk18on = "1.81" compileSdk = "36" diff --git a/kokoro/gcp_ubuntu_docker/continuous.cfg b/kokoro/gcp_ubuntu_docker/continuous.cfg index 2c3f5b7a..9597201a 100644 --- a/kokoro/gcp_ubuntu_docker/continuous.cfg +++ b/kokoro/gcp_ubuntu_docker/continuous.cfg @@ -1,27 +1,12 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" - -fileset_artifacts { - name: "androidify_phone_aab" - artifact_globs: "artifacts/app-release-unsigned.aab" - artifact_globs: "artifacts/app-release.spdx.json" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/continuous/mobile" - } +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + sbom_regex: "artifacts/app-release.spdx.json" + # Optional: Removes the "artifacts/" part from the path in the artifact storage + strip_prefix: "artifacts" + fail_if_no_artifacts: true } } - -# Fileset for the Wear OS App AAB -fileset_artifacts { - name: "androidify_wear_aab" - artifact_globs: "artifacts/wear-release-unsigned.aab" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/continuous/wear" - } - } -} - diff --git a/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_presubmit.sh b/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_presubmit.sh new file mode 100755 index 00000000..c11f235f --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_presubmit.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Fail on any error. +set -e + +# Display commands being run. +# WARNING: please only enable 'set -x' if necessary for debugging, and be very +# careful if you handle credentials (e.g. from Keystore) with 'set -x': +# statements like "export VAR=$(cat /tmp/keystore/credentials)" will result in +# the credentials being printed in build logs. +# Additionally, recursive invocation with credentials as command-line +# parameters, will print the full command, with credentials, in the build logs. +# set -x + +# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/github. +# The final directory name in this path is determined by the scm name specified +# in the job configuration. +cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" +./build_presubmit_mobile.sh diff --git a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh b/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_release.sh old mode 100644 new mode 100755 similarity index 96% rename from kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh rename to kokoro/gcp_ubuntu_docker/kokoro_build_mobile_release.sh index 05e0bdd6..57dd0b4f --- a/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh +++ b/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_release.sh @@ -16,4 +16,4 @@ set -e # The final directory name in this path is determined by the scm name specified # in the job configuration. cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" -./build_presubmit.sh +./build_release_mobile.sh \ No newline at end of file diff --git a/kokoro/gcp_ubuntu_docker/kokoro_build_wear_presubmit.sh b/kokoro/gcp_ubuntu_docker/kokoro_build_wear_presubmit.sh new file mode 100755 index 00000000..2d96b052 --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/kokoro_build_wear_presubmit.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Fail on any error. +set -e + +# Display commands being run. +# WARNING: please only enable 'set -x' if necessary for debugging, and be very +# careful if you handle credentials (e.g. from Keystore) with 'set -x': +# statements like "export VAR=$(cat /tmp/keystore/credentials)" will result in +# the credentials being printed in build logs. +# Additionally, recursive invocation with credentials as command-line +# parameters, will print the full command, with credentials, in the build logs. +# set -x + +# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/github. +# The final directory name in this path is determined by the scm name specified +# in the job configuration. +cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" +./build_presubmit_wear.sh \ No newline at end of file diff --git a/kokoro/gcp_ubuntu_docker/kokoro_build.sh b/kokoro/gcp_ubuntu_docker/kokoro_build_wear_release.sh similarity index 96% rename from kokoro/gcp_ubuntu_docker/kokoro_build.sh rename to kokoro/gcp_ubuntu_docker/kokoro_build_wear_release.sh index b30ebda8..ddb24af3 100755 --- a/kokoro/gcp_ubuntu_docker/kokoro_build.sh +++ b/kokoro/gcp_ubuntu_docker/kokoro_build_wear_release.sh @@ -16,4 +16,4 @@ set -e # The final directory name in this path is determined by the scm name specified # in the job configuration. cd "${KOKORO_ARTIFACTS_DIR}/github/androidify" -./build.sh \ No newline at end of file +./build_release_wear.sh \ No newline at end of file diff --git a/kokoro/gcp_ubuntu_docker/presubmit.cfg b/kokoro/gcp_ubuntu_docker/presubmit.cfg index f74c32ac..e1f2ff38 100644 --- a/kokoro/gcp_ubuntu_docker/presubmit.cfg +++ b/kokoro/gcp_ubuntu_docker/presubmit.cfg @@ -1,25 +1,11 @@ -build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_presubmit_build.sh" +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build_mobile_presubmit.sh" -fileset_artifacts { - name: "androidify_phone_aab" - artifact_globs: "artifacts/app-release-unsigned.aab" - artifact_globs: "artifacts/app-release.spdx.json" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/presubmit/mobile" - } - } -} - -# Fileset for the Wear OS App AAB -fileset_artifacts { - name: "androidify_wear_aab" - artifact_globs: "artifacts/wear-release-unsigned.aab" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/presubmit/wear" - } +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + sbom_regex: "artifacts/app-release.spdx.json" + strip_prefix: "artifacts" + fail_if_no_artifacts: true } } diff --git a/kokoro/gcp_ubuntu_docker/presubmit_wear.cfg b/kokoro/gcp_ubuntu_docker/presubmit_wear.cfg new file mode 100644 index 00000000..73f515e0 --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/presubmit_wear.cfg @@ -0,0 +1,10 @@ +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build_wear_presubmit.sh" + +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + strip_prefix: "artifacts" + fail_if_no_artifacts: true + } +} diff --git a/kokoro/gcp_ubuntu_docker/release.cfg b/kokoro/gcp_ubuntu_docker/release.cfg index db0d3f63..6d4f8e02 100644 --- a/kokoro/gcp_ubuntu_docker/release.cfg +++ b/kokoro/gcp_ubuntu_docker/release.cfg @@ -1,25 +1,11 @@ build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build.sh" -fileset_artifacts { - name: "androidify_phone_aab" - artifact_globs: "artifacts/app-release-unsigned.aab" - artifact_globs: "artifacts/app-release.spdx.json" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/release/mobile" - } - } -} - -# Fileset for the Wear OS App AAB -fileset_artifacts { - name: "androidify_wear_aab" - artifact_globs: "artifacts/wear-release-unsigned.aab" - destinations { - store_attestation: true - gcs { - gcs_root_path: "androidify-app-prod-kokoro-artifacts/gcp_ubuntu_docker/release/wear" - } +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + sbom_regex: "artifacts/app-release.spdx.json" + strip_prefix: "artifacts" + fail_if_no_artifacts: true } } diff --git a/kokoro/gcp_ubuntu_docker/release_wear.cfg b/kokoro/gcp_ubuntu_docker/release_wear.cfg new file mode 100644 index 00000000..53dac07f --- /dev/null +++ b/kokoro/gcp_ubuntu_docker/release_wear.cfg @@ -0,0 +1,10 @@ +build_file: "androidify/kokoro/gcp_ubuntu_docker/kokoro_build_wear_release.sh" + +action { + define_artifacts { + regex: "artifacts/**.aab" + regex: "artifacts/**.intoto.jsonl" + strip_prefix: "artifacts" + fail_if_no_artifacts: true + } +}