ci: restrict Build FreeRDP AAR workflow to main branch only #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build FreeRDP AAR | |
| # Builds the freeRDPCore AAR from the pinned FreeRDP submodule and | |
| # commits it to core/rdp/libs/ so the main app build can consume it. | |
| # Trigger: | |
| # - manually via workflow_dispatch | |
| # - automatically when the submodule pointer or this workflow changes | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.gitmodules' | |
| - 'core/rdp/FREERDP_VERSION' | |
| - '.github/workflows/freerdp-build.yml' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-aar: | |
| name: Build freeRDPCore AAR | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| env: | |
| NDK_VERSION: "26.1.10909125" | |
| CMAKE_VERSION: "3.22.1" | |
| steps: | |
| - name: Checkout with submodule | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| cache: gradle | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| packages: >- | |
| platforms;android-35 | |
| build-tools;35.0.0 | |
| ndk;26.1.10909125 | |
| cmake;3.22.1 | |
| - name: Export NDK path | |
| run: | | |
| echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VERSION" >> "$GITHUB_ENV" | |
| echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/$NDK_VERSION" >> "$GITHUB_ENV" | |
| - name: Install native build prerequisites | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build pkg-config ccache | |
| - name: Build FreeRDP native libraries + OpenSSL | |
| working-directory: freerdp | |
| env: | |
| CCACHE_DIR: ${{ github.workspace }}/.ccache | |
| run: | | |
| # Trim the upstream conf: disable FFmpeg and AAD (cJSON) to shave | |
| # ~25 minutes off the native build. MVP does not need audio/video | |
| # redirection or Azure AD (cJSON-based) auth. | |
| sed -i 's/^WITH_FFMPEG=.*/WITH_FFMPEG=0/' scripts/android-build.conf | |
| sed -i 's/^WITH_AAD=.*/WITH_AAD=0/' scripts/android-build.conf | |
| # Upstream common.sh finds cmake via: | |
| # find $ANDROID_SDK/cmake -name cmake -executable -type f -print -quit | |
| # which on modern sdkmanager installs picks up | |
| # cmake/<ver>/share/bash-completion/completions/cmake (a shell | |
| # snippet, not the real binary). That stub exits 0 when executed | |
| # directly, so the driver script reports success without building | |
| # anything. Pre-export CMAKE_PROGRAM to the real bin/cmake — the | |
| # script honours the pre-set value and skips its buggy find. | |
| REAL_CMAKE=$(find "$ANDROID_HOME/cmake" -path "*/bin/cmake" -type f -executable | head -1) | |
| if [ -z "$REAL_CMAKE" ]; then | |
| echo "::error::No real cmake binary found under $ANDROID_HOME/cmake/*/bin/" | |
| ls -la "$ANDROID_HOME/cmake/" || true | |
| exit 1 | |
| fi | |
| echo "Using real cmake: $REAL_CMAKE" | |
| "$REAL_CMAKE" --version | |
| export CMAKE_PROGRAM="$REAL_CMAKE" | |
| # android-build-freerdp.sh auto-sources scripts/android-build.conf | |
| # then accepts --ndk/--sdk/--arch via common_parse_arguments to | |
| # supply the environment values. BUILD_DEPS=1 is already on by | |
| # default in android-build.conf, so OpenSSL is pulled+built. | |
| bash scripts/android-build-freerdp.sh \ | |
| --ndk "$ANDROID_NDK_HOME" \ | |
| --sdk "$ANDROID_HOME" \ | |
| --arch arm64-v8a | |
| # Sanity check: libfreerdp3.so must have been installed into jniLibs | |
| JNI_DIR="client/Android/Studio/freeRDPCore/src/main/jniLibs/arm64-v8a" | |
| if [ ! -f "$JNI_DIR/libfreerdp3.so" ]; then | |
| echo "::error::FreeRDP build did not produce $JNI_DIR/libfreerdp3.so" | |
| ls -la "$JNI_DIR/" || true | |
| exit 1 | |
| fi | |
| echo "FreeRDP native libs installed:" | |
| ls -la "$JNI_DIR/" | |
| - name: Inject release properties for upstream Studio build | |
| working-directory: freerdp/client/Android/Studio | |
| run: | | |
| # Ensure a debug keystore exists — the upstream build.gradle | |
| # defaults RELEASE_STORE_FILE to ~/.android/debug.keystore. | |
| mkdir -p "$HOME/.android" | |
| if [ ! -f "$HOME/.android/debug.keystore" ]; then | |
| keytool -genkey -v -keystore "$HOME/.android/debug.keystore" \ | |
| -storepass android -alias androiddebugkey -keypass android \ | |
| -dname "CN=Android Debug,O=Android,C=US" \ | |
| -keyalg RSA -keysize 2048 -validity 10000 | |
| fi | |
| # Upstream build.gradle does direct Groovy assignment inside | |
| # `if (!hasProperty('RELEASE_STORE_FILE')) { RELEASE_STORE_FILE=... }` | |
| # which throws MissingPropertyException on Gradle 8+. Defining the | |
| # keys in gradle.properties makes hasProperty() true and the broken | |
| # block is skipped. | |
| cat >> gradle.properties <<EOF | |
| RELEASE_STORE_FILE=$HOME/.android/debug.keystore | |
| RELEASE_KEY_ALIAS=androiddebugkey | |
| RELEASE_KEY_PASSWORD=android | |
| RELEASE_STORE_PASSWORD=android | |
| EOF | |
| - name: Build freeRDPCore Gradle project | |
| working-directory: freerdp/client/Android/Studio | |
| env: | |
| ANDROID_HOME: ${{ env.ANDROID_HOME }} | |
| ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }} | |
| run: | | |
| # Upstream Studio project uses Groovy build.gradle (not .kts). | |
| # :freeRDPCore assembles the AAR we consume. :aFreeRDP is the | |
| # upstream demo app — skip it to save time. | |
| chmod +x ./gradlew | |
| ./gradlew :freeRDPCore:assembleRelease --no-daemon --stacktrace | |
| - name: Locate produced AAR | |
| id: locate | |
| run: | | |
| AAR=$(find freerdp/client/Android/Studio/freeRDPCore/build/outputs/aar \ | |
| -name 'freeRDPCore-release.aar' -print -quit) | |
| if [ -z "$AAR" ]; then | |
| echo "::error::AAR not found after build" | |
| exit 1 | |
| fi | |
| echo "aar_path=$AAR" >> "$GITHUB_OUTPUT" | |
| - name: Verify AAR contains arm64-v8a native libs | |
| run: | | |
| unzip -l "${{ steps.locate.outputs.aar_path }}" \ | |
| | grep -q "jni/arm64-v8a/libfreerdp-android.so" \ | |
| || { echo "::error::AAR missing arm64-v8a native lib"; exit 1; } | |
| - name: Copy AAR into core/rdp/libs | |
| run: | | |
| mkdir -p core/rdp/libs | |
| cp "${{ steps.locate.outputs.aar_path }}" core/rdp/libs/freerdp-android.aar | |
| ls -la core/rdp/libs/ | |
| - name: Commit AAR if changed | |
| run: | | |
| VERSION=$(cat core/rdp/FREERDP_VERSION) | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # `git add` handles both new-untracked and modified cases. Then | |
| # `git diff --cached --quiet` correctly detects whether the index | |
| # differs from HEAD — which covers the initial commit of a | |
| # previously untracked AAR file. | |
| git add core/rdp/libs/freerdp-android.aar | |
| if git diff --cached --quiet core/rdp/libs/freerdp-android.aar; then | |
| echo "AAR unchanged vs HEAD — nothing to commit" | |
| exit 0 | |
| fi | |
| git commit -m "chore: rebuild freerdp-android.aar against FreeRDP $VERSION" | |
| git push | |
| - name: Upload AAR artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: freerdp-android-aar | |
| path: core/rdp/libs/freerdp-android.aar | |
| if-no-files-found: error |