prefer ncc for packaging
This commit is contained in:
parent
a6bcfcc41f
commit
7c08eb9fd2
@ -13,7 +13,7 @@ inputs:
|
||||
default: ''
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/main.js'
|
||||
main: 'dist/index.js'
|
||||
branding:
|
||||
icon: 'download'
|
||||
color: 'blue'
|
||||
|
1
dist/index.js
vendored
Normal file
1
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
dist/unzip
vendored
Normal file
BIN
dist/unzip
vendored
Normal file
Binary file not shown.
47
lib/main.js
47
lib/main.js
@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const rustup = __importStar(require("./rustup"));
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const version = core.getInput('rust-version');
|
||||
const components = core.getInput('components')
|
||||
.split(',')
|
||||
.map((component) => component.trim())
|
||||
.filter((component) => component.length > 0);
|
||||
const targets = core.getInput('targets')
|
||||
.split(',')
|
||||
.map((target) => target.trim())
|
||||
.filter((target) => target.length > 0);
|
||||
if (version) {
|
||||
yield rustup.install();
|
||||
yield exec.exec('rustup', ['toolchain', 'install', version,
|
||||
...(components.length > 0 ? ['-c', ...components] : []),
|
||||
...(targets.length > 0 ? ['-t', ...targets] : []),
|
||||
]);
|
||||
yield exec.exec('rustup', ['default', version]);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
run();
|
@ -1,70 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const toolCache = __importStar(require("@actions/tool-cache"));
|
||||
const path = __importStar(require("path"));
|
||||
const os = __importStar(require("os"));
|
||||
const fs_1 = require("fs");
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
function install() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// `rustup` is already installed on Linux and Windows platforms
|
||||
if (os.platform() == 'darwin') {
|
||||
let toolPath = yield installOnUnix();
|
||||
core.debug('rustup is located under: ' + toolPath);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
}
|
||||
else {
|
||||
// Update the GitHub managed VM version of rustup
|
||||
// to leverage newer features like "latest latest compatible nightly"
|
||||
yield exec.exec('rustup', ['self', 'update']);
|
||||
yield exec.exec('rustup', ['set', 'profile', 'minimal']);
|
||||
if (os.platform() == 'win32') {
|
||||
let cargoPath = '';
|
||||
{
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
cargoPath += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
yield exec.exec('where', ['rustup.exe'], options);
|
||||
}
|
||||
let rustupPath = cargoPath.split('\\').slice(0, -3).concat([".rustup"]).join("\\");
|
||||
let defaultClearedFilePath = `${rustupPath}\\default_cleared`;
|
||||
if (!fs_1.existsSync(defaultClearedFilePath)) {
|
||||
// Github's default Windows install comes with rustup pre-installed with stable, including
|
||||
// rust-docs. This removes the default stable install so that it doesn't update rust-docs.
|
||||
fs_1.renameSync(`${rustupPath}\\toolchains`, `${rustupPath}\\_toolchains`);
|
||||
fs_1.appendFileSync(defaultClearedFilePath, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.install = install;
|
||||
function installOnUnix() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let script = yield toolCache.downloadTool("https://sh.rustup.rs");
|
||||
fs_1.chmodSync(script, '777');
|
||||
yield exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none', '--profile=minimal']);
|
||||
return path.join(process.env['HOME'] || '', '.cargo');
|
||||
});
|
||||
}
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -656,6 +656,12 @@
|
||||
"integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==",
|
||||
"dev": true
|
||||
},
|
||||
"@zeit/ncc": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
|
||||
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
|
||||
"dev": true
|
||||
},
|
||||
"abab": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"description": "Set up a specific Rust toolchain in your Github Actions workflows",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "ncc build src/main.ts --minify",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
@ -32,6 +32,7 @@
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.12.14",
|
||||
"@types/semver": "^6.0.0",
|
||||
"@zeit/ncc": "^0.21.0",
|
||||
"jest": "^24.8.0",
|
||||
"jest-circus": "^24.7.1",
|
||||
"ts-jest": "^24.0.2",
|
||||
|
Loading…
Reference in New Issue
Block a user