mirror of
https://gitea.com/actions/setup-android.git
synced 2025-12-23 15:39:52 +00:00
Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c5672355a | ||
|
|
be14762587 | ||
|
|
02a4c0fae6 | ||
|
|
4963c9b31a | ||
|
|
2741e25473 | ||
|
|
ed89994087 | ||
|
|
240c9729bd | ||
|
|
36d0d24ca4 | ||
|
|
cabf29c9ef | ||
|
|
65b8c7bc99 | ||
|
|
34f33aad26 | ||
|
|
3d201fcd51 | ||
|
|
1ba064a8a2 | ||
|
|
4360e92aa0 | ||
|
|
88c04cbb34 | ||
|
|
239c6f5c7c | ||
|
|
882b1d3cd5 | ||
|
|
00dbb341f0 | ||
|
|
c1ac9c4be4 | ||
|
|
0f0da39d59 | ||
|
|
c6c2260dde | ||
|
|
47ea489789 | ||
|
|
244317f5bb | ||
|
|
5440ded976 | ||
|
|
e94bbf69b5 | ||
|
|
98f14d164f | ||
|
|
f56c207000 | ||
|
|
a7d36b05d1 | ||
|
|
20bad8a341 | ||
|
|
fc91ea75c1 | ||
|
|
1685c3d866 | ||
|
|
62d9713f6c | ||
|
|
e2a3af499e | ||
|
|
c83cf2fad5 | ||
|
|
39db4a222a | ||
|
|
69e42af51e | ||
|
|
1eccbc5efd | ||
|
|
54a403b145 | ||
|
|
4bd635e9b7 | ||
|
|
7528b5330e | ||
|
|
c1a2a96971 | ||
|
|
a812d70a1a | ||
|
|
9bd8ed6b1f | ||
|
|
ecf659ded2 | ||
|
|
8f636b1085 | ||
|
|
be688ab050 | ||
|
|
2842aed41c | ||
|
|
bc065618ae | ||
|
|
2d34867f5a | ||
|
|
2469709471 | ||
|
|
3404b45d4c | ||
|
|
161f0b2707 | ||
|
|
ae8a1c8d80 | ||
|
|
e458de9c46 | ||
|
|
da1ab05e31 | ||
|
|
910b2809b6 | ||
|
|
7fc55be752 | ||
|
|
36160f0297 | ||
|
|
46ed96d180 | ||
|
|
57a1f875c4 | ||
|
|
cee829806b | ||
|
|
a83cba80ae | ||
|
|
53fbf5011f | ||
|
|
ef1614e11f | ||
|
|
7506bcd002 | ||
|
|
0bdb2caf82 | ||
|
|
6989f50c81 | ||
|
|
9ab2660a79 | ||
|
|
cc38275357 | ||
|
|
999dabf39c | ||
|
|
6bde8445cd | ||
|
|
1edf194eee | ||
|
|
8c02e1fcfa | ||
|
|
87280a34d4 | ||
|
|
e3e9dc9b68 | ||
|
|
fb95bc1561 | ||
|
|
0df682b3d9 | ||
|
|
0e84f1d6a4 | ||
|
|
9e5b3ce36b | ||
|
|
ebc0cbe4ab | ||
|
|
27f88822ed | ||
|
|
a9018e09bb | ||
|
|
6bb81b1f40 | ||
|
|
7b2dad077d | ||
|
|
6ef7c7f726 | ||
|
|
df284ad095 | ||
|
|
bb3313467a | ||
|
|
8c6fc62420 | ||
|
|
bd524df5da | ||
|
|
e5fc925f91 | ||
|
|
aceb0eac9b | ||
|
|
903dd50e8f | ||
|
|
ec68242df7 | ||
|
|
658d02355a |
@@ -44,6 +44,7 @@
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"i18n-text/no-en": "warn",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
|
||||
57
.github/workflows/build-test.yml
vendored
57
.github/workflows/build-test.yml
vendored
@@ -15,26 +15,29 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node 12
|
||||
uses: actions/setup-node@v2.1.2
|
||||
- name: Setup node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12'
|
||||
node-version: '16'
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm run build
|
||||
|
||||
- name: Check if dist/index.js needs to be rebuilt
|
||||
run: diff <(git status dist/index.js --short) <(echo -n "")
|
||||
|
||||
format-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node 12
|
||||
uses: actions/setup-node@v2.1.2
|
||||
- name: Setup node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12'
|
||||
node-version: '16'
|
||||
|
||||
- run: npm ci
|
||||
|
||||
@@ -43,26 +46,48 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node 12
|
||||
uses: actions/setup-node@v2.1.2
|
||||
- name: Setup node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12'
|
||||
node-version: '16'
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm test
|
||||
|
||||
runSdkManager:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
- run: node dist/index.js
|
||||
|
||||
- run: sdkmanager --list
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node 12
|
||||
uses: actions/setup-node@v2.1.2
|
||||
- name: Setup node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '12'
|
||||
node-version: '16'
|
||||
|
||||
- run: npm ci
|
||||
|
||||
|
||||
43
.github/workflows/codeql-analysis.yml
vendored
Normal file
43
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '44 12 * * 4'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: 'javascript'
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
11
.github/workflows/run.yml
vendored
11
.github/workflows/run.yml
vendored
@@ -22,19 +22,24 @@ jobs:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
- macos-latest
|
||||
|
||||
# Disabled, because daveol/SampleApplication is missing
|
||||
if: ${{ false }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: daveol/SampleApplication
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
path: ./build/
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Setup Android SDK
|
||||
id: 'setup-android'
|
||||
|
||||
19
README.md
19
README.md
@@ -3,9 +3,18 @@
|
||||

|
||||
|
||||
This action sets up the Android SDK tools by:
|
||||
- Downloading the SDK commandline tools
|
||||
- Accepting the SDK licenses
|
||||
|
||||
- Downloading the SDK commandline tools, if the current version (7.0) is not found in either `$ANDROID_SDK_ROOT` or `$HOME/.android/sdk`.
|
||||
- Accepting the SDK licenses.
|
||||
- Installing `tools` and `platform-tools`.
|
||||
- Adding `platform-tools` (contains adb) and `cmdline-tools/7.0/bin` (contains sdkmanager) to `$PATH`.
|
||||
- Setting up problem [matchers](/matchers.json).
|
||||
|
||||
On Windows 2016 runners, this action also checks if `$ANDROID_SDK_ROOT` path contains spaces.
|
||||
If it does - it moves SDK to a path without spaces. This is needed because spaces are highly problematic:
|
||||
```
|
||||
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Android\android-sdk\cmdline-tools\3.0\bin\sdkmanager.bat" --licenses"
|
||||
Error: Could not find or load main class Files
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
@@ -14,10 +23,10 @@ See [action.yml](action.yml)
|
||||
## Basic
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ author: 'Android-Actions'
|
||||
description: 'Setup the Android SDK Tools and add them to the path'
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
branding:
|
||||
|
||||
10017
dist/index.js
vendored
10017
dist/index.js
vendored
File diff suppressed because one or more lines are too long
16404
package-lock.json
generated
16404
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -5,7 +5,7 @@
|
||||
"description": "setup android action",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "ncc build src/main.ts --out dist/ --minify",
|
||||
"build": "ncc build src/main.ts --out dist/",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"lint": "eslint src/*.ts",
|
||||
@@ -25,23 +25,26 @@
|
||||
"author": "daveol",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^1.0.3",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/tool-cache": "^1.6.0"
|
||||
"@actions/cache": "^3.0.5",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"fs-extra": "^10.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.6",
|
||||
"@typescript-eslint/parser": "^4.6.1",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.12.1",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.13.1",
|
||||
"prettier": "^2.1.2",
|
||||
"ts-jest": "^24.2.0",
|
||||
"typescript": "^4.0.5"
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/jest": "^29.2.0",
|
||||
"@types/node": "^16.11.66",
|
||||
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
||||
"@typescript-eslint/parser": "^5.40.1",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-github": "^4.4.0",
|
||||
"eslint-plugin-jest": "^27.1.3",
|
||||
"jest": "^29.2.1",
|
||||
"jest-circus": "^29.2.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
}
|
||||
|
||||
200
src/main.ts
200
src/main.ts
@@ -3,9 +3,11 @@ import * as tc from '@actions/tool-cache'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import * as fse from 'fs-extra'
|
||||
import * as os from 'os'
|
||||
|
||||
const COMMANDLINE_TOOLS_VERSION = '6858069'
|
||||
const CMDLINE_TOOLS_VERSION = '7.0'
|
||||
const COMMANDLINE_TOOLS_VERSION = '8512546'
|
||||
|
||||
const COMMANDLINE_TOOLS_WIN_URL = `https://dl.google.com/android/repository/commandlinetools-win-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
||||
const COMMANDLINE_TOOLS_MAC_URL = `https://dl.google.com/android/repository/commandlinetools-mac-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
||||
@@ -14,64 +16,176 @@ const COMMANDLINE_TOOLS_LIN_URL = `https://dl.google.com/android/repository/comm
|
||||
const HOME = os.homedir()
|
||||
const ANDROID_HOME_DIR = path.join(HOME, '.android')
|
||||
const ANDROID_HOME_SDK_DIR = path.join(ANDROID_HOME_DIR, 'sdk')
|
||||
const ANDROID_REPOSITORIES_CFG = path.join(ANDROID_HOME_DIR, 'repositories.cfg')
|
||||
let ANDROID_SDK_ROOT = process.env['ANDROID_SDK_ROOT'] || ANDROID_HOME_SDK_DIR
|
||||
|
||||
async function install(): Promise<string> {
|
||||
const ANDROID_SDK_ROOT =
|
||||
process.env['ANDROID_SDK_ROOT'] || ANDROID_HOME_SDK_DIR
|
||||
const licenseDir = path.join(ANDROID_SDK_ROOT, 'licenses')
|
||||
function getSdkManagerPath(cmdToolsVersion: string): string {
|
||||
return path.join(
|
||||
ANDROID_SDK_ROOT,
|
||||
'cmdline-tools',
|
||||
cmdToolsVersion,
|
||||
'bin',
|
||||
'sdkmanager'
|
||||
)
|
||||
}
|
||||
|
||||
// If the licences exist, the rest does too
|
||||
if (fs.existsSync(licenseDir)) {
|
||||
core.debug(`Skipping install, licenseDir found: ${licenseDir}`)
|
||||
return ANDROID_SDK_ROOT
|
||||
function findPreinstalledSdkManager(): {
|
||||
isFound: boolean
|
||||
isCorrectVersion: boolean
|
||||
exePath: string
|
||||
} {
|
||||
const result = {isFound: false, isCorrectVersion: false, exePath: ''}
|
||||
|
||||
// First try to find the version defined in CMDLINE_TOOLS_VERSION
|
||||
result.exePath = getSdkManagerPath(CMDLINE_TOOLS_VERSION)
|
||||
result.isFound = fs.existsSync(result.exePath)
|
||||
if (result.isFound) {
|
||||
result.isCorrectVersion = true
|
||||
return result
|
||||
}
|
||||
|
||||
// create ~/.android/repositories.cfg
|
||||
fs.mkdirSync(ANDROID_HOME_SDK_DIR, {recursive: true})
|
||||
fs.closeSync(fs.openSync(ANDROID_REPOSITORIES_CFG, 'w'))
|
||||
// cmdline-tools could have a 'latest' version, but if it was installed 2 years ago
|
||||
// it may not be 'latest' as of today
|
||||
result.exePath = getSdkManagerPath('latest')
|
||||
result.isFound = fs.existsSync(result.exePath)
|
||||
if (result.isFound) {
|
||||
const propertiesFile = path.join(
|
||||
ANDROID_SDK_ROOT,
|
||||
'cmdline-tools',
|
||||
'latest',
|
||||
'source.properties'
|
||||
)
|
||||
if (fs.existsSync(propertiesFile)) {
|
||||
result.isCorrectVersion = fs
|
||||
.readFileSync(propertiesFile, 'utf8')
|
||||
.includes(`Pkg.Revision=${CMDLINE_TOOLS_VERSION}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
result.exePath = ''
|
||||
|
||||
// Find whatever version is available in ANDROID_SDK_ROOT
|
||||
const cmdlineToolsDir = path.join(ANDROID_SDK_ROOT, 'cmdline-tools')
|
||||
const foundVersions: string[] = fs.existsSync(cmdlineToolsDir)
|
||||
? fs.readdirSync(cmdlineToolsDir)
|
||||
: []
|
||||
const foundVersionsFiltered: string[] = foundVersions.filter(
|
||||
obj => '.' !== obj && '..' !== obj
|
||||
)
|
||||
|
||||
// Sort by desc, to get 2.0 first, before 1.0
|
||||
const foundVersionsSorted: string[] = foundVersionsFiltered.sort(
|
||||
(a: string, b: string) => (a > b ? -1 : 1)
|
||||
)
|
||||
|
||||
for (const version of foundVersionsSorted) {
|
||||
result.exePath = getSdkManagerPath(version)
|
||||
result.isFound = fs.existsSync(result.exePath)
|
||||
if (result.isFound) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
result.exePath = ''
|
||||
return result
|
||||
}
|
||||
|
||||
async function callSdkManager(sdkManager: string, arg: string): Promise<void> {
|
||||
const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8')
|
||||
let sdkManager = ''
|
||||
await exec.exec(sdkManager, [arg], {
|
||||
input: acceptBuffer
|
||||
})
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
const cmdlineToolsZip = await tc.downloadTool(COMMANDLINE_TOOLS_LIN_URL)
|
||||
const cmdlineTools = await tc.extractZip(cmdlineToolsZip)
|
||||
sdkManager = path.join(cmdlineTools, 'tools', 'bin', 'sdkmanager')
|
||||
} else if (process.platform === 'darwin') {
|
||||
const cmdlineToolsZip = await tc.downloadTool(COMMANDLINE_TOOLS_MAC_URL)
|
||||
const cmdlineTools = await tc.extractZip(cmdlineToolsZip)
|
||||
sdkManager = path.join(cmdlineTools, 'tools', 'bin', 'sdkmanager')
|
||||
} else if (process.platform === 'win32') {
|
||||
const cmdlineToolsZip = await tc.downloadTool(COMMANDLINE_TOOLS_WIN_URL)
|
||||
const cmdlineTools = await tc.extractZip(cmdlineToolsZip)
|
||||
sdkManager = path.join(cmdlineTools, 'tools', 'bin', 'sdkmanager.bat')
|
||||
} else {
|
||||
core.error(`Unsupported platform: ${process.platform}`)
|
||||
async function installSdkManager(): Promise<string> {
|
||||
fs.mkdirSync(ANDROID_SDK_ROOT, {recursive: true})
|
||||
|
||||
// touch $ANDROID_SDK_ROOT/repositories.cfg
|
||||
fs.closeSync(
|
||||
fs.openSync(path.join(ANDROID_SDK_ROOT, 'repositories.cfg'), 'w')
|
||||
)
|
||||
|
||||
const sdkManager = findPreinstalledSdkManager()
|
||||
if (!sdkManager.isFound) {
|
||||
let cmdlineToolsURL
|
||||
if (process.platform === 'linux') {
|
||||
cmdlineToolsURL = COMMANDLINE_TOOLS_LIN_URL
|
||||
} else if (process.platform === 'darwin') {
|
||||
cmdlineToolsURL = COMMANDLINE_TOOLS_MAC_URL
|
||||
} else if (process.platform === 'win32') {
|
||||
cmdlineToolsURL = COMMANDLINE_TOOLS_WIN_URL
|
||||
} else {
|
||||
core.error(`Unsupported platform: ${process.platform}`)
|
||||
return ''
|
||||
}
|
||||
const cmdlineToolsZip = await tc.downloadTool(cmdlineToolsURL)
|
||||
const cmdlineToolsExtractedLocation = await tc.extractZip(cmdlineToolsZip)
|
||||
|
||||
// Move cmdline-tools to where it would be if it was installed through sdkmanager
|
||||
// Will allow calling sdkmanager without --sdk_root='..' argument
|
||||
const desiredLocation = path.join(
|
||||
ANDROID_SDK_ROOT,
|
||||
'cmdline-tools',
|
||||
CMDLINE_TOOLS_VERSION
|
||||
)
|
||||
|
||||
// Create parent directory
|
||||
fs.mkdirSync(path.dirname(desiredLocation), {recursive: true})
|
||||
|
||||
// Make sure we don't have leftover target directory (happens sometimes...)
|
||||
if (fs.existsSync(desiredLocation)) fse.removeSync(desiredLocation)
|
||||
|
||||
// @TODO: use io.mv instead of fs-extra.moveSync once following issue is resolved:
|
||||
// https://github.com/actions/toolkit/issues/706
|
||||
fse.moveSync(
|
||||
path.join(cmdlineToolsExtractedLocation, 'cmdline-tools'),
|
||||
desiredLocation
|
||||
)
|
||||
fse.removeSync(cmdlineToolsExtractedLocation)
|
||||
|
||||
sdkManager.exePath = getSdkManagerPath(CMDLINE_TOOLS_VERSION)
|
||||
sdkManager.isCorrectVersion = true
|
||||
}
|
||||
|
||||
await exec.exec(
|
||||
sdkManager,
|
||||
['--licenses', `--sdk_root=${ANDROID_SDK_ROOT}`],
|
||||
{input: acceptBuffer}
|
||||
)
|
||||
|
||||
await exec.exec(
|
||||
sdkManager,
|
||||
['--include_obsolete', `--sdk_root=${ANDROID_SDK_ROOT}`, 'tools'],
|
||||
{input: acceptBuffer}
|
||||
)
|
||||
|
||||
return ANDROID_SDK_ROOT
|
||||
if (!sdkManager.isCorrectVersion) {
|
||||
await callSdkManager(
|
||||
sdkManager.exePath,
|
||||
`cmdline-tools;${CMDLINE_TOOLS_VERSION}`
|
||||
)
|
||||
sdkManager.exePath = getSdkManagerPath(CMDLINE_TOOLS_VERSION)
|
||||
}
|
||||
return sdkManager.exePath
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const ANDROID_SDK_ROOT = await install()
|
||||
if ('win16' === process.env['ImageOS']) {
|
||||
if (-1 !== ANDROID_SDK_ROOT.indexOf(' ')) {
|
||||
// On Windows2016, Android SDK is installed to Program Files,
|
||||
// and it doesn't really work..
|
||||
// C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Android\android-sdk\cmdline-tools\3.0\bin\sdkmanager.bat" --licenses"
|
||||
// Error: Could not find or load main class Files
|
||||
|
||||
const newSDKLocation = ANDROID_SDK_ROOT.replace(/\s/gi, '-')
|
||||
core.debug(`moving ${ANDROID_SDK_ROOT} to ${newSDKLocation}`)
|
||||
fs.mkdirSync(path.dirname(newSDKLocation), {recursive: true})
|
||||
|
||||
// intentionally using fs.renameSync,
|
||||
// because it doesn't move across drives
|
||||
fs.renameSync(ANDROID_SDK_ROOT, newSDKLocation)
|
||||
ANDROID_SDK_ROOT = newSDKLocation
|
||||
}
|
||||
}
|
||||
|
||||
const sdkManager = await installSdkManager()
|
||||
core.debug(`sdkmanager installed to: ${sdkManager}`)
|
||||
await callSdkManager(sdkManager, '--licenses')
|
||||
await callSdkManager(sdkManager, 'tools')
|
||||
await callSdkManager(sdkManager, 'platform-tools')
|
||||
|
||||
core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', COMMANDLINE_TOOLS_VERSION)
|
||||
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)
|
||||
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT)
|
||||
|
||||
core.addPath(path.join(ANDROID_SDK_ROOT, 'tools', 'bin'))
|
||||
core.addPath(path.dirname(sdkManager))
|
||||
core.addPath(path.join(ANDROID_SDK_ROOT, 'platform-tools'))
|
||||
|
||||
core.debug('add matchers')
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user