mirror of
https://github.com/android-actions/setup-android.git
synced 2026-10-02 17:41:34 +00:00
Changeup: consilidate code, drop cache, change download
This changes up way too much: - Moving most (all) of the code to main.ts instead of the numerous files - Dropping the caching functionality, since it should be optional - now we will only download the android sdk tools if they are not already present, including if ANDROID_SDK_ROOT is already set
This commit is contained in:
1 parent
57977119c1
commit
24b7e80ade
11 files changed
+70
-369
No files matched your search
+1
-3
@@ -4,9 +4,7 @@ description: 'Setup the Android SDK Tools and add them to the path'
|
|||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/main/index.js'
|
main: 'dist/index.js'
|
||||||
post: 'dist/post/index.js'
|
|
||||||
post-if: success()
|
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: 'list'
|
icon: 'list'
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(n.exports,n,n.exports,__webpack_require__);i=false}finally{if(i)delete r[t]}n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}({1:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const i=r(129);const o=r(622);const s=r(669);const a=r(672);const c=s.promisify(i.exec);function cp(e,t,r={}){return n(this,void 0,void 0,function*(){const{force:n,recursive:i}=readCopyOptions(r);const s=(yield a.exists(t))?yield a.stat(t):null;if(s&&s.isFile()&&!n){return}const c=s&&s.isDirectory()?o.join(t,o.basename(e)):t;if(!(yield a.exists(e))){throw new Error(`no such file or directory: ${e}`)}const u=yield a.stat(e);if(u.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,c,0,n)}}else{if(o.relative(e,c)===""){throw new Error(`'${c}' and '${e}' are the same file`)}yield copyFile(e,c,n)}})}t.cp=cp;function mv(e,t,r={}){return n(this,void 0,void 0,function*(){if(yield a.exists(t)){let n=true;if(yield a.isDirectory(t)){t=o.join(t,o.basename(e));n=yield a.exists(t)}if(n){if(r.force==null||r.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(o.dirname(t));yield a.rename(e,t)})}t.mv=mv;function rmRF(e){return n(this,void 0,void 0,function*(){if(a.IS_WINDOWS){try{if(yield a.isDirectory(e,true)){yield c(`rd /s /q "${e}"`)}else{yield c(`del /f /a "${e}"`)}}catch(e){if(e.code!=="ENOENT")throw e}try{yield a.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield a.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield c(`rm -rf "${e}"`)}else{yield a.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return n(this,void 0,void 0,function*(){yield a.mkdirP(e)})}t.mkdirP=mkdirP;function which(e,t){return n(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(a.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}}try{const t=[];if(a.IS_WINDOWS&&process.env.PATHEXT){for(const e of process.env.PATHEXT.split(o.delimiter)){if(e){t.push(e)}}}if(a.isRooted(e)){const r=yield a.tryGetExecutablePath(e,t);if(r){return r}return""}if(e.includes("/")||a.IS_WINDOWS&&e.includes("\\")){return""}const r=[];if(process.env.PATH){for(const e of process.env.PATH.split(o.delimiter)){if(e){r.push(e)}}}for(const n of r){const r=yield a.tryGetExecutablePath(n+o.sep+e,t);if(r){return r}}return""}catch(e){throw new Error(`which failed with message ${e.message}`)}})}t.which=which;function readCopyOptions(e){const t=e.force==null?true:e.force;const r=Boolean(e.recursive);return{force:t,recursive:r}}function cpDirRecursive(e,t,r,i){return n(this,void 0,void 0,function*(){if(r>=255)return;r++;yield mkdirP(t);const n=yield a.readdir(e);for(const o of n){const n=`${e}/${o}`;const s=`${t}/${o}`;const c=yield a.lstat(n);if(c.isDirectory()){yield cpDirRecursive(n,s,r,i)}else{yield copyFile(n,s,i)}}yield a.chmod(t,(yield a.stat(e)).mode)})}function copyFile(e,t,r){return n(this,void 0,void 0,function*(){if((yield a.lstat(e)).isSymbolicLink()){try{yield a.lstat(t);yield a.unlink(t)}catch(e){if(e.code==="EPERM"){yield a.chmod(t,"0666");yield a.unlink(t)}}const r=yield a.readlink(e);yield a.symlink(r,t,a.IS_WINDOWS?"junction":null)}else if(!(yield a.exists(t))||r){yield a.copyFile(e,t)}})}},9:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.Line truncated
|
||||||
Vendored
-1
@@ -1 +0,0 @@
|
|||||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var a=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);a=false}finally{if(a)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const a=n(129);const r=n(622);const o=n(669);const s=n(672);const c=o.promisify(a.exec);function cp(e,t,n={}){return i(this,void 0,void 0,function*(){const{force:i,recursive:a}=readCopyOptions(n);const o=(yield s.exists(t))?yield s.stat(t):null;if(o&&o.isFile()&&!i){return}const c=o&&o.isDirectory()?r.join(t,r.basename(e)):t;if(!(yield s.exists(e))){throw new Error(`no such file or directory: ${e}`)}const u=yield s.stat(e);if(u.isDirectory()){if(!a){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,c,0,i)}}else{if(r.relative(e,c)===""){throw new Error(`'${c}' and '${e}' are the same file`)}yield copyFile(e,c,i)}})}t.cp=cp;function mv(e,t,n={}){return i(this,void 0,void 0,function*(){if(yield s.exists(t)){let i=true;if(yield s.isDirectory(t)){t=r.join(t,r.basename(e));i=yield s.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(r.dirname(t));yield s.rename(e,t)})}t.mv=mv;function rmRF(e){return i(this,void 0,void 0,function*(){if(s.IS_WINDOWS){try{if(yield s.isDirectory(e,true)){yield c(`rd /s /q "${e}"`)}else{yield c(`del /f /a "${e}"`)}}catch(e){if(e.code!=="ENOENT")throw e}try{yield s.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield s.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield c(`rm -rf "${e}"`)}else{yield s.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return i(this,void 0,void 0,function*(){yield s.mkdirP(e)})}t.mkdirP=mkdirP;function which(e,t){return i(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(s.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}}try{const t=[];if(s.IS_WINDOWS&&process.env.PATHEXT){for(const e of process.env.PATHEXT.split(r.delimiter)){if(e){t.push(e)}}}if(s.isRooted(e)){const n=yield s.tryGetExecutablePath(e,t);if(n){return n}return""}if(e.includes("/")||s.IS_WINDOWS&&e.includes("\\")){return""}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(r.delimiter)){if(e){n.push(e)}}}for(const i of n){const n=yield s.tryGetExecutablePath(i+r.sep+e,t);if(n){return n}}return""}catch(e){throw new Error(`which failed with message ${e.message}`)}})}t.which=which;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);return{force:t,recursive:n}}function cpDirRecursive(e,t,n,a){return i(this,void 0,void 0,function*(){if(n>=255)return;n++;yield mkdirP(t);const i=yield s.readdir(e);for(const r of i){const i=`${e}/${r}`;const o=`${t}/${r}`;const c=yield s.lstat(i);if(c.isDirectory()){yield cpDirRecursive(i,o,n,a)}else{yield copyFile(i,o,a)}}yield s.chmod(t,(yield s.stat(e)).mode)})}function copyFile(e,t,n){return i(this,void 0,void 0,function*(){if((yield s.lstat(e)).isSymbolicLink()){try{yield s.lstat(t);yield s.unlink(t)}catch(e){if(e.code==="EPERM"){yield s.chmod(t,"0666");yield s.unlink(t)}}const n=yield s.readlink(e);yield s.symlink(n,t,s.IS_WINDOWS?"junction":null)}else if(!(yield s.exists(t))||n){yield s.copyFile(e,t)}})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function defaultGetter(e,t){return e[t]}t.defaultGetter=defaultGetter},,,,,,,function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(Line truncated
|
|
||||||
Vendored
-1
@@ -1 +0,0 @@
|
|||||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var a=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);a=false}finally{if(a)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const a=n(129);const o=n(622);const r=n(669);const s=n(672);const c=r.promisify(a.exec);function cp(e,t,n={}){return i(this,void 0,void 0,function*(){const{force:i,recursive:a}=readCopyOptions(n);const r=(yield s.exists(t))?yield s.stat(t):null;if(r&&r.isFile()&&!i){return}const c=r&&r.isDirectory()?o.join(t,o.basename(e)):t;if(!(yield s.exists(e))){throw new Error(`no such file or directory: ${e}`)}const u=yield s.stat(e);if(u.isDirectory()){if(!a){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,c,0,i)}}else{if(o.relative(e,c)===""){throw new Error(`'${c}' and '${e}' are the same file`)}yield copyFile(e,c,i)}})}t.cp=cp;function mv(e,t,n={}){return i(this,void 0,void 0,function*(){if(yield s.exists(t)){let i=true;if(yield s.isDirectory(t)){t=o.join(t,o.basename(e));i=yield s.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(o.dirname(t));yield s.rename(e,t)})}t.mv=mv;function rmRF(e){return i(this,void 0,void 0,function*(){if(s.IS_WINDOWS){try{if(yield s.isDirectory(e,true)){yield c(`rd /s /q "${e}"`)}else{yield c(`del /f /a "${e}"`)}}catch(e){if(e.code!=="ENOENT")throw e}try{yield s.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield s.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield c(`rm -rf "${e}"`)}else{yield s.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return i(this,void 0,void 0,function*(){yield s.mkdirP(e)})}t.mkdirP=mkdirP;function which(e,t){return i(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(s.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}}try{const t=[];if(s.IS_WINDOWS&&process.env.PATHEXT){for(const e of process.env.PATHEXT.split(o.delimiter)){if(e){t.push(e)}}}if(s.isRooted(e)){const n=yield s.tryGetExecutablePath(e,t);if(n){return n}return""}if(e.includes("/")||s.IS_WINDOWS&&e.includes("\\")){return""}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(o.delimiter)){if(e){n.push(e)}}}for(const i of n){const n=yield s.tryGetExecutablePath(i+o.sep+e,t);if(n){return n}}return""}catch(e){throw new Error(`which failed with message ${e.message}`)}})}t.which=which;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);return{force:t,recursive:n}}function cpDirRecursive(e,t,n,a){return i(this,void 0,void 0,function*(){if(n>=255)return;n++;yield mkdirP(t);const i=yield s.readdir(e);for(const o of i){const i=`${e}/${o}`;const r=`${t}/${o}`;const c=yield s.lstat(i);if(c.isDirectory()){yield cpDirRecursive(i,r,n,a)}else{yield copyFile(i,r,a)}}yield s.chmod(t,(yield s.stat(e)).mode)})}function copyFile(e,t,n){return i(this,void 0,void 0,function*(){if((yield s.lstat(e)).isSymbolicLink()){try{yield s.lstat(t);yield s.unlink(t)}catch(e){if(e.code==="EPERM"){yield s.chmod(t,"0666");yield s.unlink(t)}}const n=yield s.readlink(e);yield s.symlink(n,t,s.IS_WINDOWS?"junction":null)}else if(!(yield s.exists(t))||n){yield s.copyFile(e,t)}})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function defaultGetter(e,t){return e[t]}t.defaultGetter=defaultGetter},,,,,,,function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(Line truncated
|
|
||||||
Generated
-39
@@ -2170,14 +2170,6 @@
|
|||||||
"integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==",
|
"integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"axios": {
|
|
||||||
"version": "0.19.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
|
|
||||||
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
|
|
||||||
"requires": {
|
|
||||||
"follow-redirects": "1.5.10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"babel-jest": {
|
"babel-jest": {
|
||||||
"version": "24.9.0",
|
"version": "24.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.9.0.tgz",
|
||||||
@@ -3720,29 +3712,6 @@
|
|||||||
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
|
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
|
||||||
"version": "1.5.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
|
||||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
|
||||||
"requires": {
|
|
||||||
"debug": "=3.1.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"debug": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"for-in": {
|
"for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
@@ -8544,14 +8513,6 @@
|
|||||||
"async-limiter": "~1.0.0"
|
"async-limiter": "~1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xml-js": {
|
|
||||||
"version": "1.6.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
|
||||||
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
|
||||||
"requires": {
|
|
||||||
"sax": "^1.2.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml-name-validator": {
|
"xml-name-validator": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||||
|
|||||||
+3
-5
@@ -5,10 +5,10 @@
|
|||||||
"description": "setup android action",
|
"description": "setup android action",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/main.ts --out dist/main --minify && ncc build src/post.ts --out dist/post --minify",
|
"build": "ncc build src/main.ts --out dist/ --minify",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/*.ts",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"all": "npm run format && npm run lint && npm run build && npm test"
|
"all": "npm run format && npm run lint && npm run build && npm test"
|
||||||
},
|
},
|
||||||
@@ -27,9 +27,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.2",
|
"@actions/cache": "^1.0.2",
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.0",
|
||||||
"@actions/tool-cache": "^1.6.0",
|
"@actions/tool-cache": "^1.6.0"
|
||||||
"axios": "^0.19.2",
|
|
||||||
"xml-js": "^1.6.11"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.10",
|
"@types/jest": "^26.0.10",
|
||||||
|
|||||||
-189
@@ -1,189 +0,0 @@
|
|||||||
import * as glob from '@actions/glob'
|
|
||||||
import * as cache from '@actions/cache'
|
|
||||||
import * as core from '@actions/core'
|
|
||||||
import * as crypto from 'crypto'
|
|
||||||
import * as fs from 'fs'
|
|
||||||
import {platform} from 'os'
|
|
||||||
import {
|
|
||||||
GRADLE_WRAPPER_GLOB,
|
|
||||||
GRADLE_CACHE_GLOB,
|
|
||||||
GRADLE_WRAPPER_DIR,
|
|
||||||
GRADLE_CACHE_DIR,
|
|
||||||
GRADLE_WRAPPER_KEY,
|
|
||||||
GRADLE_CACHE_KEY,
|
|
||||||
ANDROID_GLOB,
|
|
||||||
ANDROID_KEY,
|
|
||||||
COMMANDLINE_TOOLS_VERSION,
|
|
||||||
ANDROID_SDK_ROOT,
|
|
||||||
ANDROID_REPOSITORIES_CACHE,
|
|
||||||
ANDROID_REPOSITORIES_CFG,
|
|
||||||
VERSION
|
|
||||||
} from './constants'
|
|
||||||
|
|
||||||
async function hashFiles(globs: string[]): Promise<string | undefined> {
|
|
||||||
const globber = await glob.create(globs.join('\n'), {
|
|
||||||
followSymbolicLinks: false
|
|
||||||
})
|
|
||||||
const hashes: Buffer[] = []
|
|
||||||
|
|
||||||
for await (const file of globber.globGenerator()) {
|
|
||||||
// skip directories
|
|
||||||
if (fs.statSync(file).isDirectory()) continue
|
|
||||||
|
|
||||||
core.debug(`hashFiles: found ${file}`)
|
|
||||||
const hash = crypto.createHash('sha256')
|
|
||||||
fs.createReadStream(file).pipe(hash)
|
|
||||||
hashes.push(hash.digest())
|
|
||||||
}
|
|
||||||
|
|
||||||
// No files hashed
|
|
||||||
if (hashes.length === 0) {
|
|
||||||
core.debug('hashFiles: no hashes in array')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop trough files
|
|
||||||
const completeHash = crypto.createHash('sha256')
|
|
||||||
for (const hash of hashes) {
|
|
||||||
completeHash.update(hash)
|
|
||||||
}
|
|
||||||
completeHash.end()
|
|
||||||
return completeHash.digest('hex')
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function preGradleWrapper(): Promise<void> {
|
|
||||||
const wrapperHash = await hashFiles(GRADLE_WRAPPER_GLOB)
|
|
||||||
const wrapperKey = `gradle-wrapper-${platform}-${wrapperHash}`
|
|
||||||
const wrapperRestoreKeys = [`gradle-wrapper-${platform}-`, `gradle-wrapper-`]
|
|
||||||
|
|
||||||
// if no wrapper is present skip trying to retrieve it
|
|
||||||
if (!wrapperHash) {
|
|
||||||
core.info('A hash for the gradle wrapper could not be generated')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapperCache = await cache.restoreCache(
|
|
||||||
[GRADLE_WRAPPER_DIR],
|
|
||||||
wrapperKey,
|
|
||||||
wrapperRestoreKeys
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!wrapperCache) {
|
|
||||||
core.info(
|
|
||||||
'Gradle wrapper cache not found, expect a download from gradle wrapper.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wrapperCache !== wrapperKey) {
|
|
||||||
core.saveState(GRADLE_WRAPPER_KEY, wrapperKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function postGradleWrapper(): Promise<void> {
|
|
||||||
const wrapperKey = core.getState(GRADLE_WRAPPER_KEY)
|
|
||||||
|
|
||||||
if (wrapperKey === '') {
|
|
||||||
core.info(
|
|
||||||
'A key for gradle wrapper was not defined, and thus there will not be a cache'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await cache.saveCache([GRADLE_WRAPPER_DIR], wrapperKey)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function preGradleCache(): Promise<void> {
|
|
||||||
const cacheHash = await hashFiles(GRADLE_CACHE_GLOB)
|
|
||||||
const cacheKey = `gradle-cache-${platform}-${cacheHash}`
|
|
||||||
const cacheRestoreKeys = [`gradle-cache-${platform}-`, `gradle-cache-`]
|
|
||||||
|
|
||||||
if (!cacheHash) {
|
|
||||||
core.info('A hash for the gradle dependencies could not be generated')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheCache = await cache.restoreCache(
|
|
||||||
[GRADLE_CACHE_DIR],
|
|
||||||
cacheKey,
|
|
||||||
cacheRestoreKeys
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!cacheCache) {
|
|
||||||
core.info('Gradle cache not found, expect dependency downloads from gradle')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cacheCache !== cacheKey) {
|
|
||||||
core.saveState(GRADLE_CACHE_KEY, cacheKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function postGradleCache(): Promise<void> {
|
|
||||||
const cacheKey = core.getState(GRADLE_CACHE_KEY)
|
|
||||||
|
|
||||||
if (cacheKey === '') {
|
|
||||||
core.info(
|
|
||||||
'A key for gradle cache was not defined, and thus there will not be a cache'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await cache.saveCache([GRADLE_CACHE_DIR], cacheKey)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function preAndroidCache(): Promise<void> {
|
|
||||||
const androidHash = await hashFiles(ANDROID_GLOB)
|
|
||||||
const androidKey = `android-${VERSION}-${platform}-${COMMANDLINE_TOOLS_VERSION}-${androidHash}`
|
|
||||||
const androidRestoreKeys = [
|
|
||||||
`android-${VERSION}-${platform}-${COMMANDLINE_TOOLS_VERSION}-`,
|
|
||||||
`android-${VERSION}-${platform}-`
|
|
||||||
]
|
|
||||||
|
|
||||||
if (!androidHash) {
|
|
||||||
core.info('A hash for the android sdk could not be generated')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const androidCache = await cache.restoreCache(
|
|
||||||
[ANDROID_SDK_ROOT, ANDROID_REPOSITORIES_CACHE, ANDROID_REPOSITORIES_CFG],
|
|
||||||
androidKey,
|
|
||||||
androidRestoreKeys
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!androidCache) {
|
|
||||||
core.info(
|
|
||||||
'Android cache not found, expect dependency downloads from gradle'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (androidCache !== androidKey) {
|
|
||||||
core.saveState(ANDROID_KEY, androidKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function postAndroidCache(): Promise<void> {
|
|
||||||
const androidKey = core.getState(ANDROID_KEY)
|
|
||||||
|
|
||||||
if (androidKey === '') {
|
|
||||||
core.info(
|
|
||||||
'A key for the android sdk was not defined, and thus there will not be a cache'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await cache.saveCache(
|
|
||||||
[ANDROID_SDK_ROOT, ANDROID_REPOSITORIES_CACHE, ANDROID_REPOSITORIES_CFG],
|
|
||||||
androidKey
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import * as os from 'os'
|
|
||||||
import * as path from 'path'
|
|
||||||
|
|
||||||
export const ANNOTATION_MATCHERS = [
|
|
||||||
'android-lint-file-matcher.json',
|
|
||||||
'android-lint-line-matcher.json',
|
|
||||||
'gradle-matcher.json',
|
|
||||||
'kotlin-error-matcher.json',
|
|
||||||
'kotlin-warning-matcher.json'
|
|
||||||
]
|
|
||||||
|
|
||||||
export const HOME = os.homedir()
|
|
||||||
|
|
||||||
export const VERSION = 'v1'
|
|
||||||
|
|
||||||
// Gradle constants
|
|
||||||
// For caching the gradle cache in ~/.gradle/cache
|
|
||||||
export const GRADLE_CACHE_GLOB = [
|
|
||||||
'**/*.gradle',
|
|
||||||
'**.gradle',
|
|
||||||
'**/gradle.properties'
|
|
||||||
]
|
|
||||||
export const GRADLE_CACHE_DIR = path.join(HOME, '.gradle', 'cache')
|
|
||||||
export const GRADLE_CACHE_KEY = 'GRADLE_CACHE_KEY'
|
|
||||||
|
|
||||||
// For caching the gradle wrapper in ~/.gradle/wrapper
|
|
||||||
export const GRADLE_WRAPPER_GLOB = ['**/gradle/wrapper/**', '**/gradlew*']
|
|
||||||
export const GRADLE_WRAPPER_DIR = path.join(HOME, '.gradle', 'wrapper')
|
|
||||||
export const GRADLE_WRAPPER_KEY = 'GRADLE_WRAPPER_KEY'
|
|
||||||
|
|
||||||
// Android constants
|
|
||||||
export const ANDROID_SDK_ROOT = path.join(HOME, 'android')
|
|
||||||
export const ANDROID_GLOB = GRADLE_CACHE_GLOB
|
|
||||||
export const ANDROID_KEY = 'ANDROID_KEY'
|
|
||||||
|
|
||||||
export const ANDROID_REPOSITORIES_DIR = path.join(HOME, '.android')
|
|
||||||
export const ANDROID_REPOSITORIES_CFG = path.join(
|
|
||||||
ANDROID_REPOSITORIES_DIR,
|
|
||||||
'repositories.cfg'
|
|
||||||
)
|
|
||||||
export const ANDROID_REPOSITORIES_CACHE = path.join(
|
|
||||||
ANDROID_REPOSITORIES_DIR,
|
|
||||||
'cache'
|
|
||||||
)
|
|
||||||
|
|
||||||
export const COMMANDLINE_TOOLS_VERSION = '6609375'
|
|
||||||
export const COMMANDLINE_TOOLS_WIN_URL = `https://dl.google.com/android/repository/commandlinetools-win-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
|
||||||
export const COMMANDLINE_TOOLS_MAC_URL = `https://dl.google.com/android/repository/commandlinetools-mac-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
|
||||||
export const COMMANDLINE_TOOLS_LIN_URL = `https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import * as fs from 'fs'
|
|
||||||
import * as path from 'path'
|
|
||||||
import * as core from '@actions/core'
|
|
||||||
import * as exec from '@actions/exec'
|
|
||||||
import * as tc from '@actions/tool-cache'
|
|
||||||
import {
|
|
||||||
ANDROID_SDK_ROOT,
|
|
||||||
COMMANDLINE_TOOLS_LIN_URL,
|
|
||||||
COMMANDLINE_TOOLS_MAC_URL,
|
|
||||||
COMMANDLINE_TOOLS_WIN_URL,
|
|
||||||
ANDROID_REPOSITORIES_CFG,
|
|
||||||
ANDROID_REPOSITORIES_DIR
|
|
||||||
} from './constants'
|
|
||||||
|
|
||||||
export async function install(): Promise<void> {
|
|
||||||
const licenseDir = path.join(ANDROID_SDK_ROOT, 'licenses')
|
|
||||||
|
|
||||||
// If the licences exist, the rest does too
|
|
||||||
if (fs.existsSync(licenseDir) && fs.existsSync(ANDROID_REPOSITORIES_CFG)) {
|
|
||||||
core.debug(`Skipping install, licenseDir found: ${licenseDir}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// create ~/.android/repositories.cfg
|
|
||||||
fs.mkdirSync(ANDROID_REPOSITORIES_DIR, {recursive: true})
|
|
||||||
fs.closeSync(fs.openSync(ANDROID_REPOSITORIES_CFG, 'w'))
|
|
||||||
|
|
||||||
const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8')
|
|
||||||
let sdkManager = ''
|
|
||||||
|
|
||||||
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}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
await exec.exec(
|
|
||||||
sdkManager,
|
|
||||||
['--licenses', `--sdk_root=${ANDROID_SDK_ROOT}`],
|
|
||||||
{input: acceptBuffer}
|
|
||||||
)
|
|
||||||
|
|
||||||
exec.exec(
|
|
||||||
sdkManager,
|
|
||||||
['--include_obsolete', `--sdk_root=${ANDROID_SDK_ROOT}`, 'tools'],
|
|
||||||
{input: acceptBuffer}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
+65
-11
@@ -1,14 +1,71 @@
|
|||||||
import * as core from '@actions/core'
|
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 path from 'path'
|
||||||
import {ANDROID_SDK_ROOT, ANNOTATION_MATCHERS} from './constants'
|
import * as fs from 'fs'
|
||||||
import {preGradleCache, preAndroidCache, preGradleWrapper} from './cache'
|
import * as os from 'os'
|
||||||
import {install} from './install'
|
|
||||||
|
const COMMANDLINE_TOOLS_VERSION = '6609375'
|
||||||
|
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`
|
||||||
|
const COMMANDLINE_TOOLS_LIN_URL = `https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINE_TOOLS_VERSION}_latest.zip`
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
// If the licences exist, the rest does too
|
||||||
|
if (fs.existsSync(licenseDir) && fs.existsSync(ANDROID_REPOSITORIES_CFG)) {
|
||||||
|
core.debug(`Skipping install, licenseDir found: ${licenseDir}`)
|
||||||
|
return ANDROID_SDK_ROOT
|
||||||
|
}
|
||||||
|
|
||||||
|
// create ~/.android/repositories.cfg
|
||||||
|
fs.mkdirSync(ANDROID_HOME_SDK_DIR, {recursive: true})
|
||||||
|
fs.closeSync(fs.openSync(ANDROID_REPOSITORIES_CFG, 'w'))
|
||||||
|
|
||||||
|
const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8')
|
||||||
|
let sdkManager = ''
|
||||||
|
|
||||||
|
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}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
// process all caching but wait for them to all complete
|
const ANDROID_SDK_ROOT = await install()
|
||||||
await Promise.all([preGradleWrapper(), preGradleCache(), preAndroidCache()])
|
|
||||||
|
|
||||||
await install()
|
|
||||||
|
|
||||||
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)
|
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)
|
||||||
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT)
|
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT)
|
||||||
@@ -17,11 +74,8 @@ async function run(): Promise<void> {
|
|||||||
core.addPath(path.join(ANDROID_SDK_ROOT, 'platform-tools'))
|
core.addPath(path.join(ANDROID_SDK_ROOT, 'platform-tools'))
|
||||||
|
|
||||||
core.debug('add matchers')
|
core.debug('add matchers')
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github')
|
|
||||||
for (const matcher of ANNOTATION_MATCHERS) {
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, matcher)}`)
|
console.log(`##[add-matcher]${path.join(__dirname, '..', 'matchers.json')}`)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
import {postAndroidCache, postGradleCache, postGradleWrapper} from './cache'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
|
||||||
await Promise.all([
|
|
||||||
postGradleCache(),
|
|
||||||
postGradleWrapper(),
|
|
||||||
postAndroidCache()
|
|
||||||
])
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
run()
|
|
||||||
Reference in new issue
Block a user