forked from researchxxl/syncthing-android
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (92 loc) · 3.98 KB
/
Copy pathcopilot-setup-steps.yml
File metadata and controls
111 lines (92 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: "Copilot Setup Steps"
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
if: github.repository_owner == 'researchxxl'
timeout-minutes: 15
permissions:
contents: read
env:
IS_COPILOT: true
steps:
- name: Checkout code including submodules
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: true
fetch-depth: 0
- name: Fetch full history and tags in submodules
run: |
git submodule foreach 'git fetch --unshallow || true'
git submodule foreach 'git fetch --tags'
- name: Setup Java
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Gradle and Android user home
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
${{ runner.temp }}/.gradle/caches
${{ runner.temp }}/.gradle/wrapper
${{ runner.temp }}/.android
key: ${{ runner.os }}-gradle-android-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-android-
- name: Set Gradle and Android user home environment variables
run: |
set -eu
echo "GRADLE_USER_HOME=${{ runner.temp }}/.gradle" >> $GITHUB_ENV
echo "ANDROID_USER_HOME=${{ runner.temp }}/.android" >> $GITHUB_ENV
# Create directories to ensure they exist
mkdir -p "${{ runner.temp }}/.gradle"
mkdir -p "${{ runner.temp }}/.android"
echo "Set GRADLE_USER_HOME to: ${{ runner.temp }}/.gradle"
echo "Set ANDROID_USER_HOME to: ${{ runner.temp }}/.android"
- name: Cache Android SDK
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
~/android-sdk
key: android-sdk-${{ runner.os }}-copilot
restore-keys: |
android-sdk-${{ runner.os }}-
- name: Get Android cmdline-tools version from gradle catalog
id: get_cmdline_tools_version
run: |
set -eu
CMDLINE_TOOLS_VERSION=$(grep 'android-cmdline-tools = ' gradle/libs.versions.toml | cut -d '"' -f 2)
echo "cmdline_tools_version=${CMDLINE_TOOLS_VERSION}" >> $GITHUB_OUTPUT
- name: Install Android SDK
run: |
set -eu
# Set environment variables (always needed regardless of cache status)
echo "ANDROID_HOME=$HOME/android-sdk" >> $GITHUB_ENV
echo "ANDROID_SDK_ROOT=$HOME/android-sdk" >> $GITHUB_ENV
echo "$HOME/android-sdk/cmdline-tools/latest/bin" >> $GITHUB_PATH
# Check if SDK is already installed (from cache)
if [ -d "$HOME/android-sdk/cmdline-tools/latest" ]; then
echo "Android SDK found in cache - skipping installation"
else
echo "Installing Android SDK from scratch"
# Install Android command line tools
SDK_TOOLS_VERSION="${{ steps.get_cmdline_tools_version.outputs.cmdline_tools_version }}"
SDK_TOOLS_FILE="commandlinetools-linux-${SDK_TOOLS_VERSION}_latest.zip"
mkdir -p $HOME/android-sdk/cmdline-tools
cd $HOME/android-sdk/cmdline-tools
wget -q "https://dl.google.com/android/repository/${SDK_TOOLS_FILE}"
unzip -q "${SDK_TOOLS_FILE}"
rm "${SDK_TOOLS_FILE}"
# Move to expected location
mv cmdline-tools latest
# Accept Android licenses (only needed for fresh installation)
yes | $HOME/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses
fi