mirror of
https://github.com/actions/setup-go.git
synced 2025-11-26 22:37:39 -05:00
Add support for .tool-versions file in setup-go, update workflow (#673)
* setup go in local * add .tool-versions file support
This commit is contained in:
@@ -15,6 +15,7 @@ process.on('uncaughtException', e => {
|
||||
// Added early exit to resolve issue with slow post action step:
|
||||
// - https://github.com/actions/setup-node/issues/878
|
||||
// https://github.com/actions/cache/pull/1217
|
||||
|
||||
export async function run(earlyExit?: boolean) {
|
||||
try {
|
||||
const cacheInput = core.getBooleanInput('cache');
|
||||
|
||||
@@ -513,6 +513,9 @@ export function parseGoVersionFile(versionFilePath: string): string {
|
||||
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
return matchGo ? matchGo[1] : '';
|
||||
} else if (path.basename(versionFilePath) === '.tool-versions') {
|
||||
const match = contents.match(/^golang\s+([^\n#]+)/m);
|
||||
return match ? match[1].trim() : '';
|
||||
}
|
||||
|
||||
return contents.trim();
|
||||
|
||||
Reference in New Issue
Block a user