mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-23 18:28:01 +02:00
Add go-version-file option (#62)
This commit is contained in:
parent
193b404f8a
commit
265edc1beb
8 changed files with 179 additions and 3 deletions
|
@ -4,6 +4,7 @@ import * as path from 'path';
|
|||
import * as semver from 'semver';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as sys from './system';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
||||
type InstallationType = 'dist' | 'manifest';
|
||||
|
@ -298,3 +299,14 @@ export function makeSemver(version: string): string {
|
|||
}
|
||||
return fullVersion;
|
||||
}
|
||||
|
||||
export function parseGoVersionFile(versionFilePath: string): string {
|
||||
const contents = fs.readFileSync(versionFilePath).toString();
|
||||
|
||||
if (path.basename(versionFilePath) === 'go.mod') {
|
||||
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
return match ? match[1] : '';
|
||||
}
|
||||
|
||||
return contents.trim();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue