添加go bin到path,执行go version测试命令
All checks were successful
Continuous Integration / GitHub Actions Test (push) Successful in 31s

This commit is contained in:
soul-walker 2024-03-12 23:16:03 +08:00
parent 8133d8a6e0
commit dd890d8341
5 changed files with 11 additions and 1 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

1
package-lock.json generated
View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1" "@actions/tool-cache": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -69,6 +69,7 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1" "@actions/tool-cache": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,7 +1,9 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as io from '@actions/io'
import os from 'os' import os from 'os'
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import cp from 'child_process'
import { getInstalledGoPath } from './install' import { getInstalledGoPath } from './install'
/** /**
@ -26,8 +28,14 @@ export async function run(): Promise<void> {
const binPath = path.join(installedPath, 'go', 'bin') const binPath = path.join(installedPath, 'go', 'bin')
getFiles(binPath) getFiles(binPath)
core.addPath(binPath)
const goPath = await io.which('go')
const goVersion = (cp.execSync(`${goPath} version`) || '').toString()
core.info(`go version cmd result is: ${goVersion}`)
core.setOutput('go-version', goVersion)
// Set outputs for other workflow steps to use // Set outputs for other workflow steps to use
core.setOutput('go-version', version) // core.setOutput('go-version', version)
} catch (error) { } catch (error) {
// Fail the workflow run if an error occurs // Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message) if (error instanceof Error) core.setFailed(error.message)