mirror of
https://github.com/android-actions/setup-android.git
synced 2024-11-23 10:02:03 +00:00
[Issue #384] Implement silent licence agreement.
This commit is contained in:
parent
423241b186
commit
aeaba18a12
6 changed files with 53 additions and 6 deletions
3
.github/workflows/build-test.yml
vendored
3
.github/workflows/build-test.yml
vendored
|
@ -59,6 +59,7 @@ jobs:
|
|||
|
||||
runSdkManager:
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: ${{ matrix.os }} - ${{ matrix.cmdline-tools-version }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -89,6 +90,8 @@ jobs:
|
|||
- run: node dist/index.js
|
||||
env:
|
||||
INPUT_CMDLINE-TOOLS-VERSION: ${{ matrix.cmdline-tools-version }}
|
||||
INPUT_ACCEPT-ANDROID-SDK-LICENSES: 'true'
|
||||
INPUT_LOG-ACCEPTED-ANDROID-SDK-LICENSES: 'false'
|
||||
|
||||
- run: sdkmanager --list
|
||||
|
||||
|
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
11
README.md
11
README.md
|
@ -64,5 +64,16 @@ To install a different version, call setup-android with desired long version as
|
|||
|
||||
Current cmdline tools version can be found at https://developer.android.com/studio#command-line-tools-only
|
||||
|
||||
|
||||
# Android SDK Licences
|
||||
|
||||
Android SDK (unsurprisingly) is not public domain software, it comes with a licence.
|
||||
|
||||
Input parameter `accept-android-sdk-licenses` decides if Android SDK licences should be agreed to on behalf of the user of this action.
|
||||
Default option is 'yes', because otherwise SDK is unusable until said licences are agreed to.
|
||||
|
||||
Licences are quite long, to prevent a wall of text in the action output, licences can be agreed to silently.
|
||||
Input parameter `log-accepted-android-sdk-licenses` controls whether licence texts should be printed or omitted from the text output. Defaults to 'true'.
|
||||
|
||||
# Thanks
|
||||
Based on the project [android-problem-matchers-action](https://github.com/jonasb/android-problem-matchers-action) from [@jonasb](https://github.com/jonasb)
|
||||
|
|
10
action.yml
10
action.yml
|
@ -8,6 +8,16 @@ inputs:
|
|||
required: false
|
||||
default: '10406996'
|
||||
|
||||
accept-android-sdk-licenses:
|
||||
description: 'Android SDK is usable only after the licence agreement. Should setup-android agree to the licences, provided by "sdkmanager --licenses"'
|
||||
required: false
|
||||
default: 'true'
|
||||
|
||||
log-accepted-android-sdk-licenses:
|
||||
description: 'Should accepted licences be logged. If not, accepted licences will be accepted silently'
|
||||
required: false
|
||||
default: 'true'
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
main: 'dist/index.js'
|
||||
|
|
10
dist/index.js
vendored
10
dist/index.js
vendored
|
@ -28183,11 +28183,12 @@ const COMMANDLINE_TOOLS_MAC_URL = `https://dl.google.com/android/repository/comm
|
|||
const COMMANDLINE_TOOLS_LIN_URL = `https://dl.google.com/android/repository/commandlinetools-linux-${VERSION_LONG}_latest.zip`;
|
||||
const ANDROID_HOME_SDK_DIR = path.join(os.homedir(), '.android', 'sdk');
|
||||
let ANDROID_SDK_ROOT = process.env['ANDROID_SDK_ROOT'] || ANDROID_HOME_SDK_DIR;
|
||||
function callSdkManager(sdkManager, arg) {
|
||||
function callSdkManager(sdkManager, arg, printOutput = true) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8');
|
||||
yield exec.exec(sdkManager, [arg], {
|
||||
input: acceptBuffer
|
||||
input: acceptBuffer,
|
||||
silent: !printOutput
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -28264,7 +28265,10 @@ function run() {
|
|||
}
|
||||
}
|
||||
const sdkManagerExe = yield installSdkManager();
|
||||
yield callSdkManager(sdkManagerExe, '--licenses');
|
||||
if (core.getBooleanInput('accept-android-sdk-licenses')) {
|
||||
core.info('Accepting Android SDK licences');
|
||||
yield callSdkManager(sdkManagerExe, '--licenses', core.getBooleanInput('log-accepted-android-sdk-licenses'));
|
||||
}
|
||||
yield callSdkManager(sdkManagerExe, 'tools');
|
||||
yield callSdkManager(sdkManagerExe, 'platform-tools');
|
||||
core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG);
|
||||
|
|
19
src/main.ts
19
src/main.ts
|
@ -38,10 +38,15 @@ const COMMANDLINE_TOOLS_LIN_URL = `https://dl.google.com/android/repository/comm
|
|||
const ANDROID_HOME_SDK_DIR = path.join(os.homedir(), '.android', 'sdk')
|
||||
let ANDROID_SDK_ROOT = process.env['ANDROID_SDK_ROOT'] || ANDROID_HOME_SDK_DIR
|
||||
|
||||
async function callSdkManager(sdkManager: string, arg: string): Promise<void> {
|
||||
async function callSdkManager(
|
||||
sdkManager: string,
|
||||
arg: string,
|
||||
printOutput: Boolean = true
|
||||
): Promise<void> {
|
||||
const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8')
|
||||
await exec.exec(sdkManager, [arg], {
|
||||
input: acceptBuffer
|
||||
input: acceptBuffer,
|
||||
silent: !printOutput
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -142,7 +147,15 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
const sdkManagerExe = await installSdkManager()
|
||||
await callSdkManager(sdkManagerExe, '--licenses')
|
||||
|
||||
if (core.getBooleanInput('accept-android-sdk-licenses')) {
|
||||
core.info('Accepting Android SDK licences')
|
||||
await callSdkManager(
|
||||
sdkManagerExe,
|
||||
'--licenses',
|
||||
core.getBooleanInput('log-accepted-android-sdk-licenses')
|
||||
)
|
||||
}
|
||||
await callSdkManager(sdkManagerExe, 'tools')
|
||||
await callSdkManager(sdkManagerExe, 'platform-tools')
|
||||
|
||||
|
|
Loading…
Reference in a new issue