|
1 | 1 | name: Setup Android toolchain |
2 | 2 | description: Set up the pinned Java and Android SDK toolchain used by OpenClaw builds. |
| 3 | +inputs: |
| 4 | + cache-mode: |
| 5 | + description: Cache authority for this job (off, restore, or read-write). |
| 6 | + required: false |
| 7 | + default: "off" |
| 8 | +outputs: |
| 9 | + cache-mode: |
| 10 | + description: Validated cache authority for downstream save gates. |
| 11 | + value: ${{ inputs.cache-mode }} |
3 | 12 | runs: |
4 | 13 | using: composite |
5 | 14 | steps: |
| 15 | + - name: Validate cache mode |
| 16 | + shell: bash |
| 17 | + env: |
| 18 | + CACHE_MODE: ${{ inputs.cache-mode }} |
| 19 | + run: | |
| 20 | + case "$CACHE_MODE" in |
| 21 | + off|restore|read-write) ;; |
| 22 | + *) |
| 23 | + echo "::error::Invalid cache-mode input: '$CACHE_MODE' (expected off, restore, or read-write)" |
| 24 | + exit 2 |
| 25 | + ;; |
| 26 | + esac |
| 27 | +
|
6 | 28 | - name: Setup Java |
7 | 29 | uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5 |
8 | 30 | with: |
9 | 31 | distribution: temurin |
10 | 32 | # Keep sdkmanager on the stable JDK path for Linux CI runners. |
11 | 33 | java-version: 17 |
12 | | - cache: gradle |
13 | | - cache-dependency-path: | |
14 | | - apps/android/**/*.gradle* |
15 | | - apps/android/**/gradle-wrapper.properties |
16 | | - apps/android/gradle/libs.versions.toml |
17 | | -
|
18 | | - - name: Cache Android SDK |
19 | | - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 |
| 34 | + |
| 35 | + - name: Setup Gradle cache |
| 36 | + if: inputs.cache-mode != 'off' |
| 37 | + uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 |
| 38 | + with: |
| 39 | + cache-provider: basic |
| 40 | + cache-read-only: ${{ inputs.cache-mode != 'read-write' }} |
| 41 | + add-job-summary: never |
| 42 | + |
| 43 | + - name: Restore Android SDK cache |
| 44 | + id: android-sdk-cache |
| 45 | + if: inputs.cache-mode != 'off' |
| 46 | + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 |
20 | 47 | with: |
21 | 48 | path: ~/.android-sdk |
22 | 49 | key: ${{ runner.os }}-android-sdk-v1-cmdline-14742923-platform-37.0-build-tools-36.0.0 |
|
56 | 83 | "platform-tools" \ |
57 | 84 | "platforms;android-37.0" \ |
58 | 85 | "build-tools;36.0.0" |
| 86 | +
|
| 87 | + - name: Save Android SDK cache |
| 88 | + if: inputs.cache-mode == 'read-write' && steps.android-sdk-cache.outputs.cache-hit != 'true' |
| 89 | + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 |
| 90 | + with: |
| 91 | + path: ~/.android-sdk |
| 92 | + key: ${{ steps.android-sdk-cache.outputs.cache-primary-key }} |
0 commit comments