Compare commits

..

6 Commits

Author SHA1 Message Date
Alif Rachmawadi
b6f5cc2b39 bump version
Some checks failed
Main workflow / Run (macos-latest) (push) Failing after 4s
Main workflow / Run (ubuntu-latest) (push) Failing after 33s
Main workflow / Run (windows-latest) (push) Has been cancelled
2019-08-26 11:54:54 +07:00
Alif Rachmawadi
ad07e49913 removed unused file 2019-08-26 11:54:54 +07:00
Alif Rachmawadi
8f119fb49d Merge pull request #2 from subosito/tool-cache-110
tool-cache 1.1.0
2019-08-26 11:49:37 +07:00
Alif Rachmawadi
1dedc0776a remove unused hacks 2019-08-26 10:59:10 +07:00
Alif Rachmawadi
e4b52bc94d update tool-cache 1.1.0 2019-08-26 10:58:41 +07:00
Alif Rachmawadi
9267b2d4d1 updated user agent 2019-08-19 22:26:44 +07:00
12 changed files with 694 additions and 784 deletions

View File

@@ -14,9 +14,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
result["default"] = mod; result["default"] = mod;
return result; return result;
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io")); const io = __importStar(require("@actions/io"));
@@ -25,8 +22,6 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const restm = __importStar(require("typed-rest-client/RestClient")); const restm = __importStar(require("typed-rest-client/RestClient"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
const v4_1 = __importDefault(require("uuid/v4"));
const exec_1 = require("@actions/exec/lib/exec");
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_DARWIN = process.platform === 'darwin'; const IS_DARWIN = process.platform === 'darwin';
const IS_LINUX = process.platform === 'linux'; const IS_LINUX = process.platform === 'linux';
@@ -122,52 +117,13 @@ function extractFile(file, destDir) {
throw new Error(`Failed to extract ${file} - it is a directory`); throw new Error(`Failed to extract ${file} - it is a directory`);
} }
if ('tar.xz' === extName()) { if ('tar.xz' === extName()) {
yield extractTarXz(file, destDir); yield tc.extractTar(file, destDir, 'x');
} }
else { else {
if (IS_DARWIN) { yield tc.extractZip(file, destDir);
yield extractZipDarwin(file, destDir);
}
else {
yield tc.extractZip(file, destDir);
}
} }
}); });
} }
/**
* Extract a tar.xz
*
* @param file path to the tar.xz
* @param dest destination directory. Optional.
* @returns path to the destination directory
*/
function extractTarXz(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!file) {
throw new Error("parameter 'file' is required");
}
dest = dest || (yield _createExtractFolder(dest));
const tarPath = yield io.which('tar', true);
yield exec_1.exec(`"${tarPath}"`, ['xC', dest, '-f', file]);
return dest;
});
}
exports.extractTarXz = extractTarXz;
function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!dest) {
dest = path.join(tempDirectory, v4_1.default());
}
yield io.mkdirP(dest);
return dest;
});
}
function extractZipDarwin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
function determineVersion(version, channel) { function determineVersion(version, channel) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (version.endsWith('.x') || version === '') { if (version.endsWith('.x') || version === '') {
@@ -179,7 +135,7 @@ function determineVersion(version, channel) {
function getLatestVersion(version, channel) { function getLatestVersion(version, channel) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const releasesUrl = `${storageUrl}/releases_${osName()}.json`; const releasesUrl = `${storageUrl}/releases_${osName()}.json`;
const rest = new restm.RestClient('setup-go'); const rest = new restm.RestClient('flutter-action');
const storage = (yield rest.get(releasesUrl)).result; const storage = (yield rest.get(releasesUrl)).result;
if (!storage) { if (!storage) {
throw new Error('unable to get latest version'); throw new Error('unable to get latest version');

View File

@@ -1,7 +0,0 @@
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.

View File

@@ -8,7 +8,7 @@
You can use this to download tools (or other files) from a download URL: You can use this to download tools (or other files) from a download URL:
``` ```js
const tc = require('@actions/tool-cache'); 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'); const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
@@ -18,7 +18,7 @@ const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v1
These can then be extracted in platform specific ways: These can then be extracted in platform specific ways:
``` ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
if (process.platform === 'win32') { if (process.platform === 'win32') {
@@ -41,7 +41,7 @@ Finally, you can cache these directories in our tool-cache. This is useful if yo
You'll often want to add it to the path as part of this step: You'll often want to add it to the path as part of this step:
``` ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const core = require('@actions/core'); const core = require('@actions/core');
@@ -54,7 +54,7 @@ core.addPath(cachedPath);
You can also cache files for reuse. You can also cache files for reuse.
``` ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0'); tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
@@ -64,7 +64,7 @@ tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
Finally, you can find directories and files you've previously cached: Finally, you can find directories and files you've previously cached:
``` ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const core = require('@actions/core'); const core = require('@actions/core');
@@ -74,7 +74,7 @@ core.addPath(nodeDirectory);
You can even find all cached versions of a tool: You can even find all cached versions of a tool:
``` ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const allNodeVersions = tc.findAllVersions('node'); const allNodeVersions = tc.findAllVersions('node');

View File

@@ -30,9 +30,10 @@ export declare function extract7z(file: string, dest?: string, _7zPath?: string)
* *
* @param file path to the tar * @param file path to the tar
* @param dest destination directory. Optional. * @param dest destination directory. Optional.
* @param flags flags for the tar. Optional.
* @returns path to the destination directory * @returns path to the destination directory
*/ */
export declare function extractTar(file: string, dest?: string): Promise<string>; export declare function extractTar(file: string, dest?: string, flags?: string): Promise<string>;
/** /**
* Extract a zip * Extract a zip
* *

View File

@@ -185,16 +185,17 @@ exports.extract7z = extract7z;
* *
* @param file path to the tar * @param file path to the tar
* @param dest destination directory. Optional. * @param dest destination directory. Optional.
* @param flags flags for the tar. Optional.
* @returns path to the destination directory * @returns path to the destination directory
*/ */
function extractTar(file, dest) { function extractTar(file, dest, flags = 'xz') {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!file) { if (!file) {
throw new Error("parameter 'file' is required"); throw new Error("parameter 'file' is required");
} }
dest = dest || (yield _createExtractFolder(dest)); dest = dest || (yield _createExtractFolder(dest));
const tarPath = yield io.which('tar', true); const tarPath = yield io.which('tar', true);
yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]); yield exec_1.exec(`"${tarPath}"`, [flags, '-C', dest, '-f', file]);
return dest; return dest;
}); });
} }
@@ -216,7 +217,12 @@ function extractZip(file, dest) {
yield extractZipWin(file, dest); yield extractZipWin(file, dest);
} }
else { else {
yield extractZipNix(file, dest); if (process.platform === 'darwin') {
yield extractZipDarwin(file, dest);
}
else {
yield extractZipNix(file, dest);
}
} }
return dest; return dest;
}); });
@@ -249,6 +255,12 @@ function extractZipNix(file, dest) {
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
}); });
} }
function extractZipDarwin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
/** /**
* Caches a directory and installs it into the tool cacheDir * Caches a directory and installs it into the tool cacheDir
* *

File diff suppressed because one or more lines are too long

View File

@@ -1,36 +1,32 @@
{ {
"_args": [ "_from": "@actions/tool-cache@^1.1.0",
[ "_id": "@actions/tool-cache@1.1.0",
"@actions/tool-cache@1.0.0",
"/Users/subosito/Code/playground/flutter-actions"
]
],
"_from": "@actions/tool-cache@1.0.0",
"_id": "@actions/tool-cache@1.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-l3zT0IfDfi5Ik5aMpnXqGHGATxN8xa9ls4ue+X/CBXpPhRMRZS4vcuh5Q9T98WAGbkysRCfhpbksTPHIcKnNwQ==", "_integrity": "sha512-Oe/R1Gxv0G699OUL9ypxk9cTwHf1uXHhpcK7kpZt8d/Sbw915ktMkfxXt9+awOfLDwyl54sLi86KGCuSvnRuIQ==",
"_location": "/@actions/tool-cache", "_location": "/@actions/tool-cache",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@actions/tool-cache@1.0.0", "raw": "@actions/tool-cache@^1.1.0",
"name": "@actions/tool-cache", "name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache", "escapedName": "@actions%2ftool-cache",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.0.0", "rawSpec": "^1.1.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.0.0" "fetchSpec": "^1.1.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.0.tgz",
"_spec": "1.0.0", "_shasum": "1a0e29f244f2b5c6989fc264581068689f9c219e",
"_where": "/Users/subosito/Code/playground/flutter-actions", "_spec": "@actions/tool-cache@^1.1.0",
"_where": "/Users/subosito/Code/subosito/flutter-action",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@actions/core": "^1.0.0", "@actions/core": "^1.0.0",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",
@@ -39,6 +35,7 @@
"typed-rest-client": "^1.4.0", "typed-rest-client": "^1.4.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"deprecated": false,
"description": "Actions tool-cache lib", "description": "Actions tool-cache lib",
"devDependencies": { "devDependencies": {
"@types/nock": "^10.0.3", "@types/nock": "^10.0.3",
@@ -54,7 +51,6 @@
"lib", "lib",
"scripts" "scripts"
], ],
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec", "homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [ "keywords": [
"exec", "exec",
@@ -74,5 +70,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "1.1.0"
} }

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "flutter-action", "name": "flutter-action",
"version": "1.1.0", "version": "1.1.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -20,9 +20,9 @@
"integrity": "sha512-ezrJSRdqtXtdx1WXlfYL85+40F7gB39jCK9P0jZVODW3W6xUYmu6ZOEc/UmmElUwhRyDRm1R4yNZu1Joq2kuQg==" "integrity": "sha512-ezrJSRdqtXtdx1WXlfYL85+40F7gB39jCK9P0jZVODW3W6xUYmu6ZOEc/UmmElUwhRyDRm1R4yNZu1Joq2kuQg=="
}, },
"@actions/tool-cache": { "@actions/tool-cache": {
"version": "1.0.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.0.tgz",
"integrity": "sha512-l3zT0IfDfi5Ik5aMpnXqGHGATxN8xa9ls4ue+X/CBXpPhRMRZS4vcuh5Q9T98WAGbkysRCfhpbksTPHIcKnNwQ==", "integrity": "sha512-Oe/R1Gxv0G699OUL9ypxk9cTwHf1uXHhpcK7kpZt8d/Sbw915ktMkfxXt9+awOfLDwyl54sLi86KGCuSvnRuIQ==",
"requires": { "requires": {
"@actions/core": "^1.0.0", "@actions/core": "^1.0.0",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "flutter-action", "name": "flutter-action",
"version": "1.1.0", "version": "1.1.1",
"private": true, "private": true,
"description": "Flutter environment for use in actions", "description": "Flutter environment for use in actions",
"main": "lib/index.js", "main": "lib/index.js",
@@ -26,7 +26,7 @@
"@actions/core": "^1.0.0", "@actions/core": "^1.0.0",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",
"@actions/io": "^1.0.0", "@actions/io": "^1.0.0",
"@actions/tool-cache": "^1.0.0", "@actions/tool-cache": "^1.1.0",
"semver": "^6.3.0", "semver": "^6.3.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },

View File

@@ -5,8 +5,6 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as restm from 'typed-rest-client/RestClient'; import * as restm from 'typed-rest-client/RestClient';
import * as semver from 'semver'; import * as semver from 'semver';
import uuidV4 from 'uuid/v4';
import {exec} from '@actions/exec/lib/exec';
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_DARWIN = process.platform === 'darwin'; const IS_DARWIN = process.platform === 'darwin';
@@ -130,58 +128,12 @@ async function extractFile(file: string, destDir: string): Promise<void> {
} }
if ('tar.xz' === extName()) { if ('tar.xz' === extName()) {
await extractTarXz(file, destDir); await tc.extractTar(file, destDir, 'x');
} else { } else {
if (IS_DARWIN) { await tc.extractZip(file, destDir);
await extractZipDarwin(file, destDir);
} else {
await tc.extractZip(file, destDir);
}
} }
} }
/**
* Extract a tar.xz
*
* @param file path to the tar.xz
* @param dest destination directory. Optional.
* @returns path to the destination directory
*/
export async function extractTarXz(
file: string,
dest?: string
): Promise<string> {
if (!file) {
throw new Error("parameter 'file' is required");
}
dest = dest || (await _createExtractFolder(dest));
const tarPath: string = await io.which('tar', true);
await exec(`"${tarPath}"`, ['xC', dest, '-f', file]);
return dest;
}
async function _createExtractFolder(dest?: string): Promise<string> {
if (!dest) {
dest = path.join(tempDirectory, uuidV4());
}
await io.mkdirP(dest);
return dest;
}
async function extractZipDarwin(file: string, dest: string): Promise<void> {
const unzipPath = path.join(
__dirname,
'..',
'scripts',
'externals',
'unzip-darwin'
);
await exec(`"${unzipPath}"`, [file], {cwd: dest});
}
async function determineVersion( async function determineVersion(
version: string, version: string,
channel: string channel: string
@@ -216,7 +168,7 @@ async function getLatestVersion(
channel: string channel: string
): Promise<string> { ): Promise<string> {
const releasesUrl: string = `${storageUrl}/releases_${osName()}.json`; const releasesUrl: string = `${storageUrl}/releases_${osName()}.json`;
const rest: restm.RestClient = new restm.RestClient('setup-go'); const rest: restm.RestClient = new restm.RestClient('flutter-action');
const storage: IFlutterStorage | null = (await rest.get<IFlutterStorage | null>( const storage: IFlutterStorage | null = (await rest.get<IFlutterStorage | null>(
releasesUrl releasesUrl
)).result; )).result;