initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
3
android-actions/setup-android-v3/.eslintignore
Normal file
3
android-actions/setup-android-v3/.eslintignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
55
android-actions/setup-android-v3/.eslintrc.json
Normal file
55
android-actions/setup-android-v3/.eslintrc.json
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["plugin:github/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/no-useless-constructor": "error",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/prefer-function-type": "warn",
|
||||
"@typescript-eslint/prefer-includes": "error",
|
||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-array-sort-compare": "error",
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"i18n-text/no-en": "off",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
12
android-actions/setup-android-v3/.github/dependabot.yml
vendored
Normal file
12
android-actions/setup-android-v3/.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
117
android-actions/setup-android-v3/.github/workflows/build-test.yml
vendored
Normal file
117
android-actions/setup-android-v3/.github/workflows/build-test.yml
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
name: Build & Test
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- 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@v4
|
||||
|
||||
- name: Setup node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm run format-check
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm test
|
||||
|
||||
runSdkManager:
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: ${{ matrix.os }} - ${{ matrix.cmdline-tools-version }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-24.04
|
||||
- ubuntu-22.04
|
||||
- ubuntu-20.04
|
||||
- macos-14
|
||||
- macos-13
|
||||
- macos-12
|
||||
- windows-2022
|
||||
- windows-2019
|
||||
cmdline-tools-version:
|
||||
- 12266719
|
||||
- 11479570
|
||||
- 11076708
|
||||
- 10406996
|
||||
- 9862592
|
||||
- 9477386
|
||||
- 9123335
|
||||
- 8512546
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
- name: Run setup-android
|
||||
uses: ./
|
||||
with:
|
||||
cmdline-tools-version: ${{ matrix.cmdline-tools-version }}
|
||||
log-accepted-android-sdk-licenses: 'false'
|
||||
|
||||
- run: sdkmanager --list_installed
|
||||
|
||||
- run: sdkmanager --list
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm run lint
|
||||
43
android-actions/setup-android-v3/.github/workflows/codeql-analysis.yml
vendored
Normal file
43
android-actions/setup-android-v3/.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@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: 'javascript'
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
47
android-actions/setup-android-v3/.github/workflows/run.yml
vendored
Normal file
47
android-actions/setup-android-v3/.github/workflows/run.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
name: Run Android build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'dist/**.js'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
- macos-latest
|
||||
|
||||
# Disabled, because daveol/SampleApplication is missing
|
||||
if: ${{ false }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: daveol/SampleApplication
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
path: ./build/
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Android SDK
|
||||
id: 'setup-android'
|
||||
uses: ./build/
|
||||
|
||||
- name: Build SampleApplication
|
||||
if: runner.os != 'windows'
|
||||
run: ./gradlew --no-daemon build
|
||||
|
||||
- name: Build SampleApplication (Windows)
|
||||
if: runner.os == 'windows'
|
||||
run: .\gradlew.bat --no-daemon build
|
||||
96
android-actions/setup-android-v3/.gitignore
vendored
Normal file
96
android-actions/setup-android-v3/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# Ignore node_modules, ncc is used to compile nodejs modules into a single file
|
||||
node_modules/
|
||||
__tests__/runner/*
|
||||
|
||||
# Ignore js files that are transpiled from ts files in src/
|
||||
lib/
|
||||
|
||||
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
.vscode/
|
||||
6
android-actions/setup-android-v3/.idea/vcs.xml
generated
Normal file
6
android-actions/setup-android-v3/.idea/vcs.xml
generated
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>
|
||||
3
android-actions/setup-android-v3/.prettierignore
Normal file
3
android-actions/setup-android-v3/.prettierignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
11
android-actions/setup-android-v3/.prettierrc.json
Normal file
11
android-actions/setup-android-v3/.prettierrc.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid",
|
||||
"parser": "typescript"
|
||||
}
|
||||
21
android-actions/setup-android-v3/LICENSE
Normal file
21
android-actions/setup-android-v3/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Dave Olsthoorn
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
100
android-actions/setup-android-v3/README.md
Normal file
100
android-actions/setup-android-v3/README.md
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# setup-android
|
||||
|
||||

|
||||
|
||||
This action sets up the Android SDK tools by:
|
||||
- Downloading the SDK commandline tools, if the current version (16.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/16.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
|
||||
|
||||
See [action.yml](action.yml)
|
||||
|
||||
## Basic
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Build SampleApplication
|
||||
run: ./gradlew --no-daemon build
|
||||
```
|
||||
|
||||
## Additional packages
|
||||
Input parameter `packages` controls which packages this action will install from Android SDK.
|
||||
|
||||
Default value is `tools platform-tools`, supply an empty string to skip installing additional packages.
|
||||
|
||||
Additional packages can be installed at a later time by calling sdkmanager manually.
|
||||
|
||||
```yaml
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
with:
|
||||
packages: ''
|
||||
|
||||
# ...
|
||||
|
||||
- run: sdkmanager tools platform-tools
|
||||
```
|
||||
|
||||
## SDK Version selection
|
||||
|
||||
Command line tools are versioned using two variables - short and long.
|
||||
Long one is the build number, used in the zip URL, short one is the human friendly version name.
|
||||
|
||||
By default, setup-android installs version 12266719 (short version 16.0).
|
||||
|
||||
To install a different version, call setup-android with desired long version as the input parameter `cmdline-tools-version`:
|
||||
```yaml
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
with:
|
||||
cmdline-tools-version: 8512546
|
||||
```
|
||||
|
||||
#### Version table
|
||||
| Short version | Long version |
|
||||
|---------------| --- |
|
||||
| 16.0 | 12266719 |
|
||||
| 13.0 | 11479570 |
|
||||
| 12.0 | 11076708 |
|
||||
| 11.0 | 10406996 |
|
||||
| 10.0 | 9862592 |
|
||||
| 9.0 | 9477386 |
|
||||
| 8.0 | 9123335 |
|
||||
| 7.0 | 8512546 |
|
||||
|
||||
Current cmdline tools version can be found at https://developer.android.com/studio#command-line-tools-only
|
||||
|
||||
|
||||
# Android SDK Licenses
|
||||
|
||||
Android SDK is not public domain software, it comes with a license.
|
||||
|
||||
Input parameter `accept-android-sdk-licenses` decides if Android SDK licenses should be agreed to on behalf of the user of this action.
|
||||
Default option is 'yes', because otherwise SDK is unusable until said licenses are agreed to.
|
||||
|
||||
licenses are quite long, to prevent a wall of text in the action output, licenses can be agreed to silently.
|
||||
Input parameter `log-accepted-android-sdk-licenses` controls whether license 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)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
describe('setup-android', () => {
|
||||
it('has sanity', async () => {
|
||||
expect(true)
|
||||
})
|
||||
})
|
||||
19
android-actions/setup-android-v3/__tests__/test.js
Normal file
19
android-actions/setup-android-v3/__tests__/test.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env node
|
||||
const absoluteFilename = __filename;
|
||||
const relativeFilename = __filename.replace(`${__dirname}/`, '');
|
||||
|
||||
// android-lint-file
|
||||
console.log(`${absoluteFilename}: Warning: checkClientTrusted is empty, which could cause insecure network traffic due to trusting arbitrary TLS/SSL certificates presented by peers [TrustAllX509TrustManager]`);
|
||||
|
||||
// android-lint-line
|
||||
console.log(`${absoluteFilename}:9: Warning: A newer version of androidx.core:core-ktx than 1.2.0-beta01 is available: 1.2.0-rc01 [GradleDependency]`);
|
||||
|
||||
// gradle
|
||||
console.log(`warning unused-exclude-by-conf the exclude dependency is not in your dependency graph, so has no effect
|
||||
${relativeFilename}:12`);
|
||||
|
||||
// kotlin-error
|
||||
console.log(`e: ${absoluteFilename}: (16, 13): Val cannot be reassigned`);
|
||||
|
||||
// kotlin-warning
|
||||
console.log(`w: ${absoluteFilename}: (19, 13): Parameter 'foo' is never used`);
|
||||
32
android-actions/setup-android-v3/action.yml
Normal file
32
android-actions/setup-android-v3/action.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
name: 'Setup Android SDK Tools'
|
||||
author: 'Android-Actions'
|
||||
description: 'Setup the Android SDK Tools and add them to the path'
|
||||
|
||||
inputs:
|
||||
cmdline-tools-version:
|
||||
description: 'cmdline-tools-version. See https://developer.android.com/studio#command-line-tools-only'
|
||||
required: false
|
||||
default: '12266719'
|
||||
|
||||
accept-android-sdk-licenses:
|
||||
description: 'Android SDK is usable only after the license agreement. Should setup-android agree to the licences, provided by "sdkmanager --licenses"'
|
||||
required: false
|
||||
default: 'true'
|
||||
|
||||
log-accepted-android-sdk-licenses:
|
||||
description: 'Should accepted licenses be logged. If not, accepted licences will be accepted silently'
|
||||
required: false
|
||||
default: 'true'
|
||||
|
||||
packages:
|
||||
description: 'Additional packages to install'
|
||||
required: false
|
||||
default: 'tools platform-tools'
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
main: 'dist/index.js'
|
||||
|
||||
branding:
|
||||
icon: 'list'
|
||||
color: 'green'
|
||||
30360
android-actions/setup-android-v3/dist/index.js
vendored
Normal file
30360
android-actions/setup-android-v3/dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
android-actions/setup-android-v3/jest.config.js
Normal file
11
android-actions/setup-android-v3/jest.config.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
72
android-actions/setup-android-v3/matchers.json
Normal file
72
android-actions/setup-android-v3/matchers.json
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "android-lint-file",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.+):\\s+(Warning|Error):\\s+(.+)\\s+\\[(.+)\\]$",
|
||||
"file": 1,
|
||||
"severity": 2,
|
||||
"message": 3,
|
||||
"code": 4,
|
||||
"kind": "file"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "android-lint-line",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.+):(\\d+):\\s+(Warning|Error):\\s+(.+)\\s+\\[(.+)\\]$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"message": 4,
|
||||
"code": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "gradle",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(error|quiet|warning|lifecycle|info|debug)\\s+(\\S+)\\s+(.+)$",
|
||||
"severity": 1,
|
||||
"code": 2,
|
||||
"message": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^([^\\s]+):([\\d]+)$",
|
||||
"file": 1,
|
||||
"line": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "kotlin-error",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^e:\\s+(\\S+):\\s+\\((\\d+),\\s+(\\d+)\\):\\s+(.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"message": 4
|
||||
}
|
||||
],
|
||||
"severity": "error"
|
||||
},
|
||||
{
|
||||
"owner": "kotlin-warning",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^w:\\s+(\\S+):\\s+\\((\\d+),\\s+(\\d+)\\):\\s+(.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"message": 4
|
||||
}
|
||||
],
|
||||
"severity": "warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
12998
android-actions/setup-android-v3/package-lock.json
generated
Normal file
12998
android-actions/setup-android-v3/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
48
android-actions/setup-android-v3/package.json
Normal file
48
android-actions/setup-android-v3/package.json
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "setup-android",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "setup android action",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "ncc build src/main.ts --out dist/",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"lint": "eslint src/*.ts",
|
||||
"test": "jest",
|
||||
"all": "npm run format && npm run lint && npm run build && npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/daveol/setup-android.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"node",
|
||||
"setup",
|
||||
"android"
|
||||
],
|
||||
"author": "daveol",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.2.4",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.5",
|
||||
"@types/node": "^20.6.5",
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@vercel/ncc": "^0.38.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-github": "^5.0.1",
|
||||
"eslint-plugin-jest": "^28.6.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^3.3.2",
|
||||
"ts-jest": "^29.1.5",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
192
android-actions/setup-android-v3/src/main.ts
Normal file
192
android-actions/setup-android-v3/src/main.ts
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
import * as core from '@actions/core'
|
||||
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 os from 'os'
|
||||
|
||||
function getVersionShort(versionLong: string): string {
|
||||
switch (versionLong) {
|
||||
case '12266719':
|
||||
return '16.0'
|
||||
case '11479570':
|
||||
return '13.0'
|
||||
case '11076708':
|
||||
return '12.0'
|
||||
case '10406996':
|
||||
return '11.0'
|
||||
case '9862592':
|
||||
return '10.0'
|
||||
case '9477386':
|
||||
return '9.0'
|
||||
case '9123335':
|
||||
return '8.0'
|
||||
case '8512546':
|
||||
return '7.0'
|
||||
default:
|
||||
return versionLong
|
||||
}
|
||||
}
|
||||
|
||||
const VERSION_LONG = core.getInput('cmdline-tools-version', {
|
||||
trimWhitespace: true
|
||||
})
|
||||
if (VERSION_LONG.includes('/') || VERSION_LONG.includes('\\')) {
|
||||
core.setFailed('Malformed cmdline-tools-version!')
|
||||
throw new Error('Malformed cmdline-tools-version!')
|
||||
}
|
||||
const VERSION_SHORT = getVersionShort(VERSION_LONG)
|
||||
|
||||
const COMMANDLINE_TOOLS_WIN_URL = `https://dl.google.com/android/repository/commandlinetools-win-${VERSION_LONG}_latest.zip`
|
||||
const COMMANDLINE_TOOLS_MAC_URL = `https://dl.google.com/android/repository/commandlinetools-mac-${VERSION_LONG}_latest.zip`
|
||||
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
|
||||
|
||||
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,
|
||||
silent: !printOutput
|
||||
})
|
||||
}
|
||||
|
||||
async function installSdkManager(): Promise<string> {
|
||||
const cmdlineTools = path.join(
|
||||
ANDROID_SDK_ROOT,
|
||||
'cmdline-tools',
|
||||
VERSION_SHORT
|
||||
)
|
||||
let sdkManagerExe = path.join(cmdlineTools, 'bin', 'sdkmanager')
|
||||
|
||||
if (!fs.existsSync(sdkManagerExe)) {
|
||||
const latestCmdlineTools = path.join(
|
||||
ANDROID_SDK_ROOT,
|
||||
'cmdline-tools',
|
||||
'latest'
|
||||
)
|
||||
const sourcePropertiesFile = path.join(
|
||||
latestCmdlineTools,
|
||||
'source.properties'
|
||||
)
|
||||
const latestSdkManagerExe = path.join(
|
||||
latestCmdlineTools,
|
||||
'bin',
|
||||
'sdkmanager'
|
||||
)
|
||||
if (
|
||||
fs.existsSync(latestCmdlineTools) &&
|
||||
fs.existsSync(sourcePropertiesFile) &&
|
||||
fs.existsSync(latestSdkManagerExe)
|
||||
) {
|
||||
const sourceProperties = fs.readFileSync(sourcePropertiesFile)
|
||||
core.info(
|
||||
`Found preinstalled sdkmanager in ${latestCmdlineTools} with following source.properties:`
|
||||
)
|
||||
core.info(sourceProperties.toString())
|
||||
if (sourceProperties.includes(`Pkg.Revision=${VERSION_SHORT}`)) {
|
||||
core.info(`Preinstalled sdkmanager has the correct version`)
|
||||
sdkManagerExe = latestSdkManagerExe
|
||||
} else {
|
||||
core.info(`Wrong version in preinstalled sdkmanager`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(sdkManagerExe)) {
|
||||
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 ''
|
||||
}
|
||||
|
||||
core.info(`Downloading commandline tools from ${cmdlineToolsURL}`)
|
||||
const cmdlineToolsZip = await tc.downloadTool(cmdlineToolsURL)
|
||||
|
||||
const extractTo = path.join(ANDROID_SDK_ROOT, 'cmdline-tools')
|
||||
await tc.extractZip(cmdlineToolsZip, extractTo)
|
||||
|
||||
// Make sure we don't have leftover target directory (happens sometimes...)
|
||||
if (fs.existsSync(cmdlineTools)) {
|
||||
core.info(`Removing leftovers from ${cmdlineTools}`)
|
||||
fs.rmSync(cmdlineTools, {recursive: true})
|
||||
}
|
||||
fs.renameSync(path.join(extractTo, 'cmdline-tools'), cmdlineTools)
|
||||
}
|
||||
|
||||
// touch $ANDROID_SDK_ROOT/repositories.cfg
|
||||
fs.closeSync(
|
||||
fs.openSync(path.join(ANDROID_SDK_ROOT, 'repositories.cfg'), 'w')
|
||||
)
|
||||
core.debug(`sdkmanager available at: ${sdkManagerExe}`)
|
||||
return sdkManagerExe
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
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 sdkManagerExe = await installSdkManager()
|
||||
|
||||
if (core.getBooleanInput('accept-android-sdk-licenses')) {
|
||||
core.info('Accepting Android SDK licenses')
|
||||
await callSdkManager(
|
||||
sdkManagerExe,
|
||||
'--licenses',
|
||||
core.getBooleanInput('log-accepted-android-sdk-licenses')
|
||||
)
|
||||
}
|
||||
|
||||
const packages = core
|
||||
.getInput('packages', {required: false})
|
||||
.split(' ')
|
||||
.map(function (str) {
|
||||
return str.trim()
|
||||
})
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
||||
.filter(function (element, index, array) {
|
||||
return element
|
||||
})
|
||||
for (const pkg of packages) {
|
||||
await callSdkManager(sdkManagerExe, pkg)
|
||||
}
|
||||
|
||||
core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG)
|
||||
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)
|
||||
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT)
|
||||
|
||||
core.addPath(path.dirname(sdkManagerExe))
|
||||
core.addPath(path.join(ANDROID_SDK_ROOT, 'platform-tools'))
|
||||
|
||||
core.debug('add matchers')
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`##[add-matcher]${path.join(__dirname, '..', 'matchers.json')}`)
|
||||
}
|
||||
|
||||
run()
|
||||
13
android-actions/setup-android-v3/tsconfig.json
Normal file
13
android-actions/setup-android-v3/tsconfig.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"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'. */
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue