Consume toolkit from npmjs (#16)
This commit is contained in:
parent
a8e7064d5b
commit
40205d2e16
|
@ -0,0 +1,7 @@
|
|||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
|
@ -4,4 +4,78 @@
|
|||
|
||||
## Usage
|
||||
|
||||
See [src/core.ts](src/core.ts).
|
||||
#### Inputs/Outputs
|
||||
|
||||
You can use this library to get inputs or set outputs:
|
||||
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
|
||||
const myInput = core.getInput('inputName', { required: true });
|
||||
|
||||
// Do stuff
|
||||
|
||||
core.setOutput('outputKey', 'outputVal');
|
||||
```
|
||||
|
||||
#### Exporting variables/secrets
|
||||
|
||||
You can also export variables and secrets for future steps. Variables get set in the environment automatically, while secrets must be scoped into the environment from a workflow using `{{ secret.FOO }}`. Secrets will also be masked from the logs:
|
||||
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
|
||||
// Do stuff
|
||||
|
||||
core.exportVariable('envVar', 'Val');
|
||||
core.exportSecret('secretVar', variableWithSecretValue);
|
||||
```
|
||||
|
||||
#### PATH Manipulation
|
||||
|
||||
You can explicitly add items to the path for all remaining steps in a workflow:
|
||||
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
|
||||
core.addPath('pathToTool');
|
||||
```
|
||||
|
||||
#### Exit codes
|
||||
|
||||
You should use this library to set the failing exit code for your action:
|
||||
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
|
||||
try {
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
// setFailed logs the message and sets a failing exit code
|
||||
core.setFailed(`Action failed with error ${err}`);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### Logging
|
||||
|
||||
Finally, this library provides some utilities for logging:
|
||||
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
|
||||
const myInput = core.getInput('input');
|
||||
try {
|
||||
core.debug('Inside try block');
|
||||
|
||||
if (!myInput) {
|
||||
core.warning('myInput wasnt set');
|
||||
}
|
||||
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
core.error('Error ${err}, action may still succeed though');
|
||||
}
|
||||
```
|
||||
|
|
|
@ -16,11 +16,7 @@ export declare enum ExitCode {
|
|||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
Failure = 1,
|
||||
/**
|
||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
||||
*/
|
||||
Neutral = 78
|
||||
Failure = 1
|
||||
}
|
||||
/**
|
||||
* sets env variable for this action and future actions in the job
|
||||
|
@ -54,10 +50,6 @@ export declare function getInput(name: string, options?: InputOptions): string;
|
|||
* @param value value to store
|
||||
*/
|
||||
export declare function setOutput(name: string, value: string): void;
|
||||
/**
|
||||
* Sets the action status to neutral
|
||||
*/
|
||||
export declare function setNeutral(): void;
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
|
|
|
@ -15,10 +15,6 @@ var ExitCode;
|
|||
* A code indicating that the action was a failure
|
||||
*/
|
||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
||||
/**
|
||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
||||
*/
|
||||
ExitCode[ExitCode["Neutral"] = 78] = "Neutral";
|
||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
||||
//-----------------------------------------------------------------------
|
||||
// Variables
|
||||
|
@ -80,13 +76,6 @@ exports.setOutput = setOutput;
|
|||
//-----------------------------------------------------------------------
|
||||
// Results
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the action status to neutral
|
||||
*/
|
||||
function setNeutral() {
|
||||
process.exitCode = ExitCode.Neutral;
|
||||
}
|
||||
exports.setNeutral = setNeutral;
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,8CAAY,CAAA;AACd,CAAC,EAfW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAenB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED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,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC"}
|
|
@ -1,29 +1,29 @@
|
|||
{
|
||||
"_from": "file:toolkit\\actions-core-0.0.0.tgz",
|
||||
"_id": "@actions/core@0.0.0",
|
||||
"_from": "@actions/core@^1.0.0",
|
||||
"_id": "@actions/core@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-aA3W5QTRIbaRxEDo/Pn/unVB+PB6Vbyx2QNjnV35QRDsdhbMd65e3Gige0NCkjoJ3P+P1Fv5B9jb7XV78yUBIQ==",
|
||||
"_integrity": "sha512-aMIlkx96XH4E/2YZtEOeyrYQfhlas9jIRkfGPqMwXD095Rdkzo4lB6ZmbxPQSzD+e1M+Xsm98ZhuSMYGv/AlqA==",
|
||||
"_location": "/@actions/core",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "file",
|
||||
"where": "E:\\github\\setup-java",
|
||||
"raw": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@actions/core@^1.0.0",
|
||||
"name": "@actions/core",
|
||||
"escapedName": "@actions%2fcore",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "file:toolkit/actions-core-0.0.0.tgz",
|
||||
"saveSpec": "file:toolkit\\actions-core-0.0.0.tgz",
|
||||
"fetchSpec": "E:\\github\\setup-java\\toolkit\\actions-core-0.0.0.tgz"
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/",
|
||||
"/@actions/tool-cache"
|
||||
],
|
||||
"_resolved": "E:\\github\\setup-java\\toolkit\\actions-core-0.0.0.tgz",
|
||||
"_shasum": "5c7a8cdd3b464dedd87d453965943c15aad1dd9a",
|
||||
"_spec": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
||||
"_where": "E:\\github\\setup-java",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz",
|
||||
"_shasum": "4a090a2e958cc300b9ea802331034d5faf42d239",
|
||||
"_spec": "@actions/core@^1.0.0",
|
||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-java",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
|
@ -40,6 +40,7 @@
|
|||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"keywords": [
|
||||
"core",
|
||||
|
@ -59,5 +60,5 @@
|
|||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
|
@ -1,7 +1,60 @@
|
|||
# `@actions/exec`
|
||||
|
||||
> Functions necessary for running tools on the command line
|
||||
|
||||
## Usage
|
||||
|
||||
See [src/exec.ts](src/exec.ts).
|
||||
#### Basic
|
||||
|
||||
You can use this package to execute your tools on the command line in a cross platform way:
|
||||
|
||||
```
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
await exec.exec('node index.js');
|
||||
```
|
||||
|
||||
#### Args
|
||||
|
||||
You can also pass in arg arrays:
|
||||
|
||||
```
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
await exec.exec('node', ['index.js', 'foo=bar']);
|
||||
```
|
||||
|
||||
#### Output/options
|
||||
|
||||
Capture output or specify [other options](https://github.com/actions/toolkit/blob/d9347d4ab99fd507c0b9104b2cf79fb44fcc827d/packages/exec/src/interfaces.ts#L5):
|
||||
|
||||
```
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
const myOutput = '';
|
||||
const myError = '';
|
||||
|
||||
const options = {};
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
myOutput += data.toString();
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
myError += data.toString();
|
||||
}
|
||||
};
|
||||
options.cwd = './lib';
|
||||
|
||||
await exec.exec('node', ['index.js', 'foo=bar'], options);
|
||||
```
|
||||
|
||||
#### Exec tools not in the PATH
|
||||
|
||||
You can use it in conjunction with the `which` function from `@actions/io` to execute tools that are not in the PATH:
|
||||
|
||||
```
|
||||
const exec = require('@actions/exec');
|
||||
const io = require('@actions/io');
|
||||
|
||||
const pythonPath: string = await io.which('python', true)
|
||||
|
||||
await exec.exec(`"${pythonPath}"`, ['main.py']);
|
||||
```
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
{
|
||||
"_from": "file:toolkit\\actions-exec-0.0.0.tgz",
|
||||
"_id": "@actions/exec@0.0.0",
|
||||
"_from": "@actions/exec@^1.0.0",
|
||||
"_id": "@actions/exec@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Ha//34XKSv82P6QaaLwNK9cUJA2qzqPxRm1Cv0Wgj3k1ppS9MPjuCKQGvZI0CsbEs3UFq+NPorcbiAKM8smJWw==",
|
||||
"_integrity": "sha512-nquH0+XKng+Ll7rZfCojN7NWSbnGh+ltwUJhzfbLkmOJgxocGX2/yXcZLMyT9fa7+tByEow/NSTrBExNlEj9fw==",
|
||||
"_location": "/@actions/exec",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "file",
|
||||
"where": "E:\\github\\setup-java",
|
||||
"raw": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@actions/exec@^1.0.0",
|
||||
"name": "@actions/exec",
|
||||
"escapedName": "@actions%2fexec",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "file:toolkit/actions-exec-0.0.0.tgz",
|
||||
"saveSpec": "file:toolkit\\actions-exec-0.0.0.tgz",
|
||||
"fetchSpec": "E:\\github\\setup-java\\toolkit\\actions-exec-0.0.0.tgz"
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/",
|
||||
"/@actions/tool-cache"
|
||||
],
|
||||
"_resolved": "E:\\github\\setup-java\\toolkit\\actions-exec-0.0.0.tgz",
|
||||
"_shasum": "85d7bb181b39e3d8861a91c4f07cb09842efc3e4",
|
||||
"_spec": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
|
||||
"_where": "E:\\github\\setup-java",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.0.tgz",
|
||||
"_shasum": "70c8b698c9baa02965c07da5f0b185ca56f0a955",
|
||||
"_spec": "@actions/exec@^1.0.0",
|
||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-java",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
|
@ -31,7 +31,7 @@
|
|||
"deprecated": false,
|
||||
"description": "Actions exec lib",
|
||||
"devDependencies": {
|
||||
"@actions/io": "^0.0.0"
|
||||
"@actions/io": "^1.0.0"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
|
@ -40,6 +40,7 @@
|
|||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||
"keywords": [
|
||||
"exec",
|
||||
|
@ -59,5 +60,5 @@
|
|||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
|
@ -4,46 +4,50 @@
|
|||
|
||||
## Usage
|
||||
|
||||
#### mkdir -p
|
||||
|
||||
Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:
|
||||
|
||||
```
|
||||
/**
|
||||
* Copies a file or folder.
|
||||
*
|
||||
* @param source source path
|
||||
* @param dest destination path
|
||||
* @param options optional. See CopyOptions.
|
||||
*/
|
||||
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
|
||||
const io = require('@actions/io');
|
||||
|
||||
/**
|
||||
* Remove a path recursively with force
|
||||
*
|
||||
* @param path path to remove
|
||||
*/
|
||||
export function rmRF(path: string): Promise<void>
|
||||
await io.mkdirP('path/to/make');
|
||||
```
|
||||
|
||||
/**
|
||||
* Make a directory. Creates the full path with folders in between
|
||||
*
|
||||
* @param p path to create
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
export function mkdirP(p: string): Promise<void>
|
||||
#### cp/mv
|
||||
|
||||
/**
|
||||
* Moves a path.
|
||||
*
|
||||
* @param source source path
|
||||
* @param dest destination path
|
||||
* @param options optional. See CopyOptions.
|
||||
*/
|
||||
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void>
|
||||
Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):
|
||||
|
||||
/**
|
||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
||||
*
|
||||
* @param tool name of the tool
|
||||
* @param options optional. See WhichOptions.
|
||||
* @returns Promise<string> path to tool
|
||||
*/
|
||||
export function which(tool: string, options?: WhichOptions): Promise<string>
|
||||
```
|
||||
```
|
||||
const io = require('@actions/io');
|
||||
|
||||
// Recursive must be true for directories
|
||||
const options = { recursive: true, force: false }
|
||||
|
||||
await io.cp('path/to/directory', 'path/to/dest', options);
|
||||
await io.mv('path/to/file', 'path/to/dest');
|
||||
```
|
||||
|
||||
#### rm -rf
|
||||
|
||||
Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.
|
||||
|
||||
```
|
||||
const io = require('@actions/io');
|
||||
|
||||
await io.rmRF('path/to/directory');
|
||||
await io.rmRF('path/to/file');
|
||||
```
|
||||
|
||||
#### which
|
||||
|
||||
Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
|
||||
|
||||
```
|
||||
const exec = require('@actions/exec');
|
||||
const io = require('@actions/io');
|
||||
|
||||
const pythonPath: string = await io.which('python', true)
|
||||
|
||||
await exec.exec(`"${pythonPath}"`, ['main.py']);
|
||||
```
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
{
|
||||
"_from": "file:toolkit\\actions-io-0.0.0.tgz",
|
||||
"_id": "@actions/io@0.0.0",
|
||||
"_from": "@actions/io@^1.0.0",
|
||||
"_id": "@actions/io@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-BZqiiacJkzERkYIMUQWrujLZWSFHEA6bD/LzR7QSDHpx32+PPk7NaUNmt8CG+y+OlYPc/ZZGaY3368K1ppfptA==",
|
||||
"_integrity": "sha512-ezrJSRdqtXtdx1WXlfYL85+40F7gB39jCK9P0jZVODW3W6xUYmu6ZOEc/UmmElUwhRyDRm1R4yNZu1Joq2kuQg==",
|
||||
"_location": "/@actions/io",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "file",
|
||||
"where": "E:\\github\\setup-java",
|
||||
"raw": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@actions/io@^1.0.0",
|
||||
"name": "@actions/io",
|
||||
"escapedName": "@actions%2fio",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "file:toolkit/actions-io-0.0.0.tgz",
|
||||
"saveSpec": "file:toolkit\\actions-io-0.0.0.tgz",
|
||||
"fetchSpec": "E:\\github\\setup-java\\toolkit\\actions-io-0.0.0.tgz"
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/",
|
||||
"/@actions/tool-cache"
|
||||
],
|
||||
"_resolved": "E:\\github\\setup-java\\toolkit\\actions-io-0.0.0.tgz",
|
||||
"_shasum": "64c85baec8d8ed889a5fb8e2ef794e36a692eeb8",
|
||||
"_spec": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
|
||||
"_where": "E:\\github\\setup-java",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz",
|
||||
"_shasum": "379454174660623bb5b3bce0be8b9e2285a62bcb",
|
||||
"_spec": "@actions/io@^1.0.0",
|
||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-java",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
|
@ -37,6 +37,7 @@
|
|||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
||||
"keywords": [
|
||||
"io",
|
||||
|
@ -56,5 +57,5 @@
|
|||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
|
@ -4,4 +4,79 @@
|
|||
|
||||
## Usage
|
||||
|
||||
See [src/tool-cache.ts](src/tool-cache.ts).
|
||||
#### Download
|
||||
|
||||
You can use this to download tools (or other files) from a download URL:
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
```
|
||||
|
||||
#### Extract
|
||||
|
||||
These can then be extracted in platform specific ways:
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
|
||||
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
|
||||
|
||||
// Or alternately
|
||||
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
|
||||
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
else {
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
```
|
||||
|
||||
#### Cache
|
||||
|
||||
Finally, you can cache these directories in our tool-cache. This is useful if you want to switch back and forth between versions of a tool, or save a tool between runs for private runners (private runners are still in development but are on the roadmap).
|
||||
|
||||
You'll often want to add it to the path as part of this step:
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
const core = require('@actions/core');
|
||||
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
||||
|
||||
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
|
||||
core.addPath(cachedPath);
|
||||
```
|
||||
|
||||
You can also cache files for reuse.
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
|
||||
```
|
||||
|
||||
#### Find
|
||||
|
||||
Finally, you can find directories and files you've previously cached:
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
const core = require('@actions/core');
|
||||
|
||||
const nodeDirectory = tc.find('node', '12.x', 'x64');
|
||||
core.addPath(nodeDirectory);
|
||||
```
|
||||
|
||||
You can even find all cached versions of a tool:
|
||||
|
||||
```
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
const allNodeVersions = tc.findAllVersions('node');
|
||||
console.log(`Versions of node available: ${allNodeVersions}`);
|
||||
```
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
{
|
||||
"_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
||||
"_id": "@actions/tool-cache@0.0.0",
|
||||
"_from": "@actions/tool-cache@^1.0.0",
|
||||
"_id": "@actions/tool-cache@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-CCJjXKGfqR34oo1mgKpUk63g3fcoIq+aNJBZ7b73aWGot0ddju2cefJrKjhEun4FI7gYsLYg+ayAUnbFwkGd4Q==",
|
||||
"_integrity": "sha512-l3zT0IfDfi5Ik5aMpnXqGHGATxN8xa9ls4ue+X/CBXpPhRMRZS4vcuh5Q9T98WAGbkysRCfhpbksTPHIcKnNwQ==",
|
||||
"_location": "/@actions/tool-cache",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "file",
|
||||
"where": "E:\\github\\setup-java",
|
||||
"raw": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@actions/tool-cache@^1.0.0",
|
||||
"name": "@actions/tool-cache",
|
||||
"escapedName": "@actions%2ftool-cache",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||
"saveSpec": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
||||
"fetchSpec": "E:\\github\\setup-java\\toolkit\\actions-tool-cache-0.0.0.tgz"
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "E:\\github\\setup-java\\toolkit\\actions-tool-cache-0.0.0.tgz",
|
||||
"_shasum": "223a115ab2782ba0a7ad4a0a829030b9cb84eade",
|
||||
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||
"_where": "E:\\github\\setup-java",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.0.0.tgz",
|
||||
"_shasum": "a9ac414bd2e0bf1f5f0302f029193c418d344c09",
|
||||
"_spec": "@actions/tool-cache@^1.0.0",
|
||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-java",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@actions/core": "^0.0.0",
|
||||
"@actions/exec": "^0.0.0",
|
||||
"@actions/io": "^0.0.0",
|
||||
"@actions/core": "^1.0.0",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/io": "^1.0.0",
|
||||
"semver": "^6.1.0",
|
||||
"typed-rest-client": "^1.4.0",
|
||||
"uuid": "^3.3.2"
|
||||
|
@ -51,6 +51,7 @@
|
|||
"lib",
|
||||
"scripts"
|
||||
],
|
||||
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||
"keywords": [
|
||||
"exec",
|
||||
|
@ -70,5 +71,5 @@
|
|||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
@ -5,24 +5,28 @@
|
|||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "file:toolkit/actions-core-0.0.0.tgz",
|
||||
"integrity": "sha512-aA3W5QTRIbaRxEDo/Pn/unVB+PB6Vbyx2QNjnV35QRDsdhbMd65e3Gige0NCkjoJ3P+P1Fv5B9jb7XV78yUBIQ=="
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz",
|
||||
"integrity": "sha512-aMIlkx96XH4E/2YZtEOeyrYQfhlas9jIRkfGPqMwXD095Rdkzo4lB6ZmbxPQSzD+e1M+Xsm98ZhuSMYGv/AlqA=="
|
||||
},
|
||||
"@actions/exec": {
|
||||
"version": "file:toolkit/actions-exec-0.0.0.tgz",
|
||||
"integrity": "sha512-Ha//34XKSv82P6QaaLwNK9cUJA2qzqPxRm1Cv0Wgj3k1ppS9MPjuCKQGvZI0CsbEs3UFq+NPorcbiAKM8smJWw=="
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.0.tgz",
|
||||
"integrity": "sha512-nquH0+XKng+Ll7rZfCojN7NWSbnGh+ltwUJhzfbLkmOJgxocGX2/yXcZLMyT9fa7+tByEow/NSTrBExNlEj9fw=="
|
||||
},
|
||||
"@actions/io": {
|
||||
"version": "file:toolkit/actions-io-0.0.0.tgz",
|
||||
"integrity": "sha512-BZqiiacJkzERkYIMUQWrujLZWSFHEA6bD/LzR7QSDHpx32+PPk7NaUNmt8CG+y+OlYPc/ZZGaY3368K1ppfptA=="
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz",
|
||||
"integrity": "sha512-ezrJSRdqtXtdx1WXlfYL85+40F7gB39jCK9P0jZVODW3W6xUYmu6ZOEc/UmmElUwhRyDRm1R4yNZu1Joq2kuQg=="
|
||||
},
|
||||
"@actions/tool-cache": {
|
||||
"version": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||
"integrity": "sha512-CCJjXKGfqR34oo1mgKpUk63g3fcoIq+aNJBZ7b73aWGot0ddju2cefJrKjhEun4FI7gYsLYg+ayAUnbFwkGd4Q==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.0.0.tgz",
|
||||
"integrity": "sha512-l3zT0IfDfi5Ik5aMpnXqGHGATxN8xa9ls4ue+X/CBXpPhRMRZS4vcuh5Q9T98WAGbkysRCfhpbksTPHIcKnNwQ==",
|
||||
"requires": {
|
||||
"@actions/core": "^0.0.0",
|
||||
"@actions/exec": "^0.0.0",
|
||||
"@actions/io": "^0.0.0",
|
||||
"@actions/core": "^1.0.0",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/io": "^1.0.0",
|
||||
"semver": "^6.1.0",
|
||||
"typed-rest-client": "^1.4.0",
|
||||
"uuid": "^3.3.2"
|
||||
|
|
11
package.json
11
package.json
|
@ -22,11 +22,12 @@
|
|||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
|
||||
"@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
|
||||
"@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
|
||||
"@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||
"semver": "^6.1.1"
|
||||
"@actions/core": "^1.0.0",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/io": "^1.0.0",
|
||||
"@actions/tool-cache": "^1.0.0",
|
||||
"semver": "^6.1.1",
|
||||
"typed-rest-client": "1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.13",
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue