diff --git a/.github/workflows/release_tools.yaml b/.github/workflows/release_tools.yaml new file mode 100644 index 0000000000..ec7d5e5c4d --- /dev/null +++ b/.github/workflows/release_tools.yaml @@ -0,0 +1,97 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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 +# +# http://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. + +name: Release CHIP Tools + +on: + workflow_dispatch: + inputs: + commit: + description: "Release tag name or commit SHA:" + required: true + publishRelease: + description: "Publish release packages (if true, 'commit' must contain a release tag name):" + required: true + default: "false" + +jobs: + android: + name: Build Android + timeout-minutes: 60 + + runs-on: ubuntu-latest + + env: + JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64/ + + container: + image: connectedhomeip/chip-build-android:0.4.33 + volumes: + - "/tmp/log_output:/tmp/test_logs" + - "/tmp/output_binaries:/tmp/output_binaries" + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: "${{ github.event.inputs.commit }}" + submodules: true + - name: Bootstrap + timeout-minutes: 10 + run: scripts/build/gn_bootstrap.sh + - name: Build arm CHIPTool + timeout-minutes: 10 + run: | + ./scripts/examples/android_app.sh --cpu arm --build-apk + cp app/build/outputs/apk/debug/app-debug.apk /tmp/output_binaries/chiptool-arm.apk + - name: Build arm64 CHIPTool + timeout-minutes: 10 + run: | + ./scripts/examples/android_app.sh --cpu arm64 --build-apk + cp app/build/outputs/apk/debug/app-debug.apk /tmp/output_binaries/chiptool-arm64.apk + - name: Install Python CHIP Controller dependencies + timeout-minutes: 10 + run: | + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -sc) main restricted" > /etc/apt/sources.list.d/arm64.list + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -sc)-updates main restricted" >> /etc/apt/sources.list.d/arm64.list + apt update + dpkg --add-architecture arm64 + apt -fy install --no-install-recommends g++-aarch64-linux-gnu libgirepository1.0-dev + apt -fy install --no-install-recommends libavahi-client-dev:arm64 libglib2.0-dev:arm64 libssl-dev:arm64 + - name: Build x64 Python CHIP Controller + timeout-minutes: 10 + run: | + gn gen out/python_x64 --args='chip_mdns="platform"' + ninja -C out/python_x64 python + cp ./out/python_x64/controller/python/chip-*.whl /tmp/output_binaries/ + - name: Build arm64 Python CHIP Controller + timeout-minutes: 10 + run: | + gn gen out/python_arm64 --args='chip_mdns="platform" custom_toolchain="//build/toolchain/custom" target_cc="aarch64-linux-gnu-gcc" target_cxx="aarch64-linux-gnu-g++" target_ar="aarch64-linux-gnu-ar" target_cpu="arm64"' + ninja -C out/python_arm64 python + cp ./out/python_arm64/controller/python/chip-*.whl /tmp/output_binaries/ + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: chip + path: /tmp/output_binaries/* + - name: Upload release packages + uses: softprops/action-gh-release@v1 + if: github.event.inputs.publishRelease == 'true' + with: + files: /tmp/output_binaries/* + fail_on_unmatched_files: true + tag_name: "${{ github.event.inputs.commit }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/examples/android_app.sh b/scripts/examples/android_app.sh index 8b8739618a..9c4a11466b 100755 --- a/scripts/examples/android_app.sh +++ b/scripts/examples/android_app.sh @@ -16,29 +16,74 @@ # limitations under the License. # -set -e -set -x -env - -if [ -z "$ANDROID_HOME" ]; then - echo "ANDROID_HOME not set!" +help() { + echo "Usage: $0 [--sdk ANDROID-SDK-HOME] [--ndk ANDROID-NDK-HOME] [--cpu TARGET-CPU] [--build-apk]" >&2 + echo " ANDROID-SDK-HOME path to Android SDK (defaults to \$ANDROID_HOME)" >&2 + echo " ANDROID-NDK-HOME path to Android NDK (defaults to \$ANDROID_NDK_HOME)" >&2 + echo " TARGET_CPU target CPU, either arm, arm64 or x64 (defaults to \$TARGET_CPU)" >&2 exit 1 -fi +} -if [ -z "$ANDROID_NDK_HOME" ]; then - echo "ANDROID_NDK_HOME not set!" - exit 1 -fi +declare -i BUILD_APK -if [ -z "$TARGET_CPU" ]; then - echo "TARGET_CPU not set! Candidates: arm, arm64, x86 and x64." - exit 1 -fi +while (($#)); do + case "$1" in + --sdk) + ANDROID_HOME="$2" + shift + ;; + --ndk) + ANDROID_NDK_HOME="$2" + shift + ;; + --cpu) + TARGET_CPU="$2" + shift + ;; + --build-apk) + BUILD_APK=1 + ;; + --help | -h) + help + ;; + *) + echo -e "Unknown option $1\n" >&2 + help + ;; + esac + shift +done + +[[ -n "$ANDROID_HOME" ]] || { + echo -e "ANDROID_HOME is not set\n" >&2 + help +} + +[[ -n "$ANDROID_NDK_HOME" ]] || { + echo -e "ANDROID_NDK_HOME is not set\n" >&2 + help +} + +[[ -n "$TARGET_CPU" ]] || { + echo -e "TARGET_CPU is not set\n" >&2 + help +} + +set -e +set -x +env # Build shared CHIP libs +BUILD_DIR="out/android_$TARGET_CPU" source scripts/activate.sh -gn gen --check --fail-on-unused-args out/"android_$TARGET_CPU" --args="target_os=\"android\" target_cpu=\"$TARGET_CPU\" android_ndk_root=\"$ANDROID_NDK_HOME\" android_sdk_root=\"$ANDROID_HOME\"" -ninja -C out/"android_$TARGET_CPU" src/setup_payload/java src/controller/java default +gn gen --check --fail-on-unused-args "$BUILD_DIR" --args="target_os=\"android\" target_cpu=\"$TARGET_CPU\" android_ndk_root=\"$ANDROID_NDK_HOME\" android_sdk_root=\"$ANDROID_HOME\"" +ninja -C "$BUILD_DIR" src/setup_payload/java src/controller/java default -rsync -a out/"android_$TARGET_CPU"/lib/*.jar src/android/CHIPTool/app/libs -rsync -a out/"android_$TARGET_CPU"/lib/jni/* src/android/CHIPTool/app/src/main/jniLibs +rsync -a "$BUILD_DIR"/lib/*.jar src/android/CHIPTool/app/libs +rsync -a "$BUILD_DIR"/lib/jni/* src/android/CHIPTool/app/src/main/jniLibs + +# Build CHIPTook APK if requested +if ((BUILD_APK)); then + yes | "$ANDROID_HOME"/tools/bin/sdkmanager --licenses + (cd src/android/CHIPTool && ./gradlew build) +fi