mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Add go-version to action outputs
This provides the semver version of Go that has been installed. This is useful if only a major or minor version has been provided as the input go-version value.
This commit is contained in:
parent
bf7ccf173e
commit
2930331465
3 changed files with 17 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
name: 'Setup Go environment'
|
name: 'Setup Go environment'
|
||||||
description: 'Setup a Go environment and add it to the PATH'
|
description: 'Setup a Go environment and add it to the PATH'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
go-version:
|
go-version:
|
||||||
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.'
|
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.'
|
||||||
check-latest:
|
check-latest:
|
||||||
|
@ -10,6 +10,9 @@ inputs:
|
||||||
token:
|
token:
|
||||||
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
outputs:
|
||||||
|
go-version:
|
||||||
|
description: 'The installed Go version. Useful when given a version range as input.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
6
dist/index.js
vendored
6
dist/index.js
vendored
|
@ -2100,6 +2100,12 @@ function run() {
|
||||||
let goPath = yield io.which('go');
|
let goPath = yield io.which('go');
|
||||||
let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
||||||
core.info(goVersion);
|
core.info(goVersion);
|
||||||
|
// get the installed version as an Action output
|
||||||
|
// based on go/src/cmd/go/internal/version/version.go:
|
||||||
|
// fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
// expecting go<version> for runtime.Version()
|
||||||
|
let goVersionOutput = [...goVersion.split(' ')[2]].slice(2).join('');
|
||||||
|
core.setOutput('go-version', goVersionOutput);
|
||||||
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();
|
||||||
core.info(goEnv);
|
core.info(goEnv);
|
||||||
|
|
|
@ -48,6 +48,13 @@ export async function run() {
|
||||||
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
||||||
core.info(goVersion);
|
core.info(goVersion);
|
||||||
|
|
||||||
|
// get the installed version as an Action output
|
||||||
|
// based on go/src/cmd/go/internal/version/version.go:
|
||||||
|
// fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
// expecting go<version> for runtime.Version()
|
||||||
|
let goVersionOutput = [...goVersion.split(' ')[2]].slice(2).join('');
|
||||||
|
core.setOutput('go-version', goVersionOutput);
|
||||||
|
|
||||||
core.startGroup('go env');
|
core.startGroup('go env');
|
||||||
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
||||||
core.info(goEnv);
|
core.info(goEnv);
|
||||||
|
|
Loading…
Add table
Reference in a new issue