mirror of
https://github.com/actions/setup-go
synced 2024-12-22 22:32:42 +00:00
add bin to path
This commit is contained in:
parent
e0b6a4d694
commit
9c31f591e9
3 changed files with 35 additions and 1 deletions
3
.github/workflows/versions.yml
vendored
3
.github/workflows/versions.yml
vendored
|
@ -43,8 +43,9 @@ jobs:
|
||||||
- name: validate version
|
- name: validate version
|
||||||
run: go version | grep "go1.12.9"
|
run: go version | grep "go1.12.9"
|
||||||
|
|
||||||
- name: show cache
|
- name: dump env
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
echo $PATH
|
||||||
echo go versions in tool cache:
|
echo go versions in tool cache:
|
||||||
echo $(ls $RUNNER_TOOL_CACHE/go)
|
echo $(ls $RUNNER_TOOL_CACHE/go)
|
||||||
|
|
17
dist/index.js
vendored
17
dist/index.js
vendored
|
@ -4576,11 +4576,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const tc = __importStar(__webpack_require__(533));
|
const tc = __importStar(__webpack_require__(533));
|
||||||
|
const cm = __importStar(__webpack_require__(470));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(280));
|
const semver = __importStar(__webpack_require__(280));
|
||||||
const httpm = __importStar(__webpack_require__(539));
|
const httpm = __importStar(__webpack_require__(539));
|
||||||
const sys = __importStar(__webpack_require__(737));
|
const sys = __importStar(__webpack_require__(737));
|
||||||
const core_1 = __webpack_require__(470);
|
const core_1 = __webpack_require__(470);
|
||||||
|
const cp = __importStar(__webpack_require__(129));
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
function downloadGo(versionSpec, stable) {
|
function downloadGo(versionSpec, stable) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let toolPath;
|
let toolPath;
|
||||||
|
@ -4602,6 +4605,7 @@ function downloadGo(versionSpec, stable) {
|
||||||
// extracts with a root folder that matches the fileName downloaded
|
// extracts with a root folder that matches the fileName downloaded
|
||||||
const toolRoot = path.join(extPath, 'go');
|
const toolRoot = path.join(extPath, 'go');
|
||||||
toolPath = yield tc.cacheDir(toolRoot, 'go', makeSemver(match.version));
|
toolPath = yield tc.cacheDir(toolRoot, 'go', makeSemver(match.version));
|
||||||
|
addBinToPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
@ -4611,6 +4615,19 @@ function downloadGo(versionSpec, stable) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.downloadGo = downloadGo;
|
exports.downloadGo = downloadGo;
|
||||||
|
function addBinToPath() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let buf = cp.execSync('go env GOPATH');
|
||||||
|
if (buf) {
|
||||||
|
let d = buf.toString().trim();
|
||||||
|
let bp = path.join(d, 'bin');
|
||||||
|
if (fs.existsSync(bp)) {
|
||||||
|
cm.addPath(bp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addBinToPath = addBinToPath;
|
||||||
function findMatch(versionSpec, stable) {
|
function findMatch(versionSpec, stable) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = sys.getArch();
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as cm from '@actions/core';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
import * as sys from './system';
|
import * as sys from './system';
|
||||||
import {debug} from '@actions/core';
|
import {debug} from '@actions/core';
|
||||||
|
import * as cp from 'child_process';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
export async function downloadGo(
|
export async function downloadGo(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
|
@ -34,6 +37,8 @@ export async function downloadGo(
|
||||||
// extracts with a root folder that matches the fileName downloaded
|
// extracts with a root folder that matches the fileName downloaded
|
||||||
const toolRoot = path.join(extPath, 'go');
|
const toolRoot = path.join(extPath, 'go');
|
||||||
toolPath = await tc.cacheDir(toolRoot, 'go', makeSemver(match.version));
|
toolPath = await tc.cacheDir(toolRoot, 'go', makeSemver(match.version));
|
||||||
|
|
||||||
|
addBinToPath();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to download version ${versionSpec}: ${error}`);
|
throw new Error(`Failed to download version ${versionSpec}: ${error}`);
|
||||||
|
@ -55,6 +60,17 @@ export interface IGoVersion {
|
||||||
files: IGoVersionFile[];
|
files: IGoVersionFile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function addBinToPath() {
|
||||||
|
let buf = cp.execSync('go env GOPATH');
|
||||||
|
if (buf) {
|
||||||
|
let d = buf.toString().trim();
|
||||||
|
let bp = path.join(d, 'bin');
|
||||||
|
if (fs.existsSync(bp)) {
|
||||||
|
cm.addPath(bp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function findMatch(
|
export async function findMatch(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean
|
stable: boolean
|
||||||
|
|
Loading…
Reference in a new issue