Skip to content

Commit

Permalink
Testing setup-android
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis committed May 4, 2024
1 parent 946accd commit 68f8d69
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/actions/setup-android/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🤖 Setup Android
description: Setup Android build tools

inputs:
android-version:
description: Android version
required: true
default: "34"
build-tools-version:
description: Build tools version https://developer.android.com/tools/releases/build-tools
required: true
default: 34.0.0
cmd-line-version:
description: Command line tools https://developer.android.com/studio#command-line-tools-only
required: true
default: "11076708"

runs:
using: composite
steps:
- uses: actions/cache@v4
id: cache
with:
key: ${{ runner.os }}-android-${{ inputs.android-version }}-tools-${{ inputs.build-tools-version }}-cmd-${{ inputs.cmd-line-version }}-zip
path: /opt/android

- name: Installing…
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir --parents /opt/android
# Export environment variables
{
echo "ANDROID_HOME=/opt/android"
echo "ANDROID_SDK_ROOT=/opt/android"
} >> $GITHUB_ENV
# Install Android Command Line Tools
curl "https://dl.google.com/android/repository/commandlinetools-linux-${CMD_LINE_VERSION}_latest.zip" -o /tmp/cmd-tools.zip \
&& unzip -d "$ANDROID_HOME" /tmp/cmd-tools.zip \
&& mv "$ANDROID_HOME"/cmdline-tools "$ANDROID_HOME"/latest \
&& mkdir "$ANDROID_HOME"/cmdline-tools \
&& mv "$ANDROID_HOME"/latest "$ANDROID_HOME"/cmdline-tools/latest
# Update PATH
{
echo "$ANDROID_HOME/tools"
echo "$ANDROID_HOME/tools/bin"
echo "$ANDROID_HOME/platform-tools"
echo "$ANDROID_HOME/cmdline-tools/latest/bin"
} >> $GITHUB_PATH
# Install Android SDKs
yes | sdkmanager --licenses --sdk_root="$ANDROID_HOME" \
&& sdkmanager --update --sdk_root="$ANDROID_HOME" \
&& sdkmanager --install --sdk_root="$ANDROID_HOME" \
"build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-${ANDROID_VERSION}" \
"platform-tools" \
"extras;android;m2repository" \
"extras;google;m2repository" \
&& sdkmanager --list
env:
ANDROID_VERSION: ${{ inputs.android-version }}
BUILD_TOOLS_VERSION: ${{ inputs.build-tools-version }}
CMD_LINE_VERSION: ${{ inputs.cmd-line-version }}
10 changes: 10 additions & 0 deletions .github/workflows/testing-setup-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 🤖 Testing setup-android

on: pull_request

jobs:
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

0 comments on commit 68f8d69

Please sign in to comment.