mirror of
https://github.com/android-actions/setup-android
synced 2024-11-26 06:58:26 -08:00
Several fixes
These include - register ANDROID_SDK_ROOT - add some license hash handling
This commit is contained in:
parent
060ba01b7f
commit
9e58d95cb5
2 changed files with 18 additions and 4 deletions
4
.github/workflows/run-test.yml
vendored
4
.github/workflows/run-test.yml
vendored
|
@ -32,8 +32,8 @@ jobs:
|
||||||
- name: Run sdkmanager
|
- name: Run sdkmanager
|
||||||
if: runner.os != 'windows'
|
if: runner.os != 'windows'
|
||||||
run: |
|
run: |
|
||||||
sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;30.0.1"
|
sdkmanager --update
|
||||||
- name: Run sdkmanager
|
- name: Run sdkmanager
|
||||||
if: runner.os == 'windows'
|
if: runner.os == 'windows'
|
||||||
run: |
|
run: |
|
||||||
sdkmanager.bat --sdk_root=${ANDROID_HOME} "build-tools;30.0.1"
|
sdkmanager.bat --update
|
||||||
|
|
18
src/main.ts
18
src/main.ts
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as tc from '@actions/tool-cache'
|
import * as tc from '@actions/tool-cache'
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const matchers = [
|
const matchers = [
|
||||||
'android-lint-file-matcher.json',
|
'android-lint-file-matcher.json',
|
||||||
|
@ -10,6 +11,10 @@ const matchers = [
|
||||||
'kotlin-warning-matcher.json'
|
'kotlin-warning-matcher.json'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const licenses = {
|
||||||
|
'android-sdk-license': '\n24333f8a63b6825ea9c5514f83c2829b004d1fee'
|
||||||
|
}
|
||||||
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMP'] || ''
|
let tempDirectory = process.env['RUNNER_TEMP'] || ''
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
@ -49,17 +54,26 @@ async function run(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
const androidHome = path.join(tempDir, 'android')
|
const androidHome = path.join(tempDir, 'android')
|
||||||
|
const cmdlineTools = path.join(androidHome, 'cmdline-tools')
|
||||||
|
|
||||||
const cmdToolsZip = await tc.downloadTool(
|
const cmdToolsZip = await tc.downloadTool(
|
||||||
`https://dl.google.com/android/repository/commandlinetools-${cmdToolsOS}-${cmdToolsVersion}_latest.zip`
|
`https://dl.google.com/android/repository/commandlinetools-${cmdToolsOS}-${cmdToolsVersion}_latest.zip`
|
||||||
)
|
)
|
||||||
|
|
||||||
core.debug('extract android commandlinetools')
|
core.debug('extract android commandlinetools')
|
||||||
await tc.extractZip(cmdToolsZip, androidHome)
|
await tc.extractZip(cmdToolsZip, cmdlineTools)
|
||||||
|
|
||||||
core.exportVariable('ANDROID_HOME', androidHome)
|
core.exportVariable('ANDROID_HOME', androidHome)
|
||||||
|
core.exportVariable('ANDROID_SDK_ROOT', androidHome)
|
||||||
|
|
||||||
core.addPath(path.join(androidHome, 'tools', 'bin'))
|
core.addPath(path.join(cmdlineTools, 'tools', 'bin'))
|
||||||
|
|
||||||
|
const licenseDir = path.join(androidHome, 'licenses')
|
||||||
|
fs.existsSync(licenseDir) || fs.mkdirSync(licenseDir)
|
||||||
|
for (const [licenseName, licenseHash] of Object.entries(licenses)) {
|
||||||
|
const licenseFile = path.join(licenseDir, licenseName)
|
||||||
|
fs.appendFileSync(licenseFile, licenseHash)
|
||||||
|
}
|
||||||
|
|
||||||
core.debug('add matchers')
|
core.debug('add matchers')
|
||||||
const matchersPath = path.join(__dirname, '..', '.github')
|
const matchersPath = path.join(__dirname, '..', '.github')
|
||||||
|
|
Loading…
Reference in a new issue