mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
add env
This commit is contained in:
parent
a3d889c34c
commit
9afdf6ea4a
2 changed files with 32 additions and 2 deletions
12
dist/setup/index.js
vendored
12
dist/setup/index.js
vendored
|
@ -63617,6 +63617,9 @@ function run() {
|
||||||
core.setOutput('go-version', parseGoVersion(goVersion));
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
core.startGroup('go env');
|
core.startGroup('go env');
|
||||||
let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString();
|
let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString();
|
||||||
|
let goEnvJson = convertEnvStringToJson(goEnv);
|
||||||
|
core.info(`go env json: ${goEnvJson}`);
|
||||||
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
core.info(goEnv);
|
core.info(goEnv);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -63664,6 +63667,15 @@ function parseGoVersion(versionString) {
|
||||||
return versionString.split(' ')[2].slice('go'.length);
|
return versionString.split(' ')[2].slice('go'.length);
|
||||||
}
|
}
|
||||||
exports.parseGoVersion = parseGoVersion;
|
exports.parseGoVersion = parseGoVersion;
|
||||||
|
function convertEnvStringToJson(envString) {
|
||||||
|
const envArray = envString.split('\n');
|
||||||
|
const envObject = {};
|
||||||
|
envArray.forEach(envVar => {
|
||||||
|
const [key, value] = envVar.split('=');
|
||||||
|
envObject[key] = value;
|
||||||
|
});
|
||||||
|
return envObject;
|
||||||
|
}
|
||||||
function resolveVersionInput() {
|
function resolveVersionInput() {
|
||||||
let version = core.getInput('go-version');
|
let version = core.getInput('go-version');
|
||||||
const versionFilePath = core.getInput('go-version-file');
|
const versionFilePath = core.getInput('go-version-file');
|
||||||
|
|
22
src/main.ts
22
src/main.ts
|
@ -3,8 +3,8 @@ import * as io from '@actions/io';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import { restoreCache } from './cache-restore';
|
||||||
import {isCacheFeatureAvailable} from './cache-utils';
|
import { isCacheFeatureAvailable } from './cache-utils';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
@ -80,6 +80,12 @@ export async function run() {
|
||||||
|
|
||||||
core.startGroup('go env');
|
core.startGroup('go env');
|
||||||
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
||||||
|
|
||||||
|
let goEnvJson = convertEnvStringToJson(goEnv)
|
||||||
|
|
||||||
|
core.info(`go env json: ${goEnvJson}`);
|
||||||
|
|
||||||
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
core.info(goEnv);
|
core.info(goEnv);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -126,6 +132,18 @@ export function parseGoVersion(versionString: string): string {
|
||||||
return versionString.split(' ')[2].slice('go'.length);
|
return versionString.split(' ')[2].slice('go'.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertEnvStringToJson(envString: string): { [key: string]: string } {
|
||||||
|
const envArray = envString.split('\n');
|
||||||
|
const envObject: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
envArray.forEach(envVar => {
|
||||||
|
const [key, value] = envVar.split('=');
|
||||||
|
envObject[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return envObject;
|
||||||
|
}
|
||||||
|
|
||||||
function resolveVersionInput(): string {
|
function resolveVersionInput(): string {
|
||||||
let version = core.getInput('go-version');
|
let version = core.getInput('go-version');
|
||||||
const versionFilePath = core.getInput('go-version-file');
|
const versionFilePath = core.getInput('go-version-file');
|
||||||
|
|
Loading…
Add table
Reference in a new issue