1
0
Fork 0
mirror of https://github.com/actions/setup-go synced 2024-11-09 15:12:40 +00:00

use golang-dl release data

This commit is contained in:
Alif Rachmawadi 2019-09-05 13:09:55 +07:00
parent 595aed780b
commit 21620fff65
No known key found for this signature in database
GPG key ID: 79DA63C0F3A55BB1
5 changed files with 10207 additions and 2496 deletions

10196
__tests__/data/golang-dl.json Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -43,9 +43,10 @@ describe('installer tests', () => {
describe('the latest release of a go version', () => {
beforeEach(() => {
nock('https://api.github.com')
.get('/repos/golang/go/git/refs/tags')
.replyWithFile(200, path.join(dataDir, 'golang-tags.json'));
nock('https://golang.org')
.get('/dl/')
.query({mode: 'json', include: 'all'})
.replyWithFile(200, path.join(dataDir, 'golang-dl.json'));
});
afterEach(() => {

View file

@ -186,10 +186,9 @@ function getLatestVersion(version) {
function getAvailableVersions() {
return __awaiter(this, void 0, void 0, function* () {
let rest = new restm.RestClient('setup-go');
let tags = (yield rest.get('https://api.github.com/repos/golang/go/git/refs/tags')).result || [];
return tags
.filter(tag => tag.ref.match(/go\d+\.[\w\.]+/g))
.map(tag => tag.ref.replace('refs/tags/go', ''));
let tags = (yield rest.get('https://golang.org/dl/?mode=json&include=all'))
.result || [];
return tags.map(tag => tag.version.replace('go', ''));
});
}
function getPossibleVersions(version) {

View file

@ -187,19 +187,16 @@ async function getLatestVersion(version: string): Promise<string> {
}
interface IGoRef {
ref: string;
version: string;
}
async function getAvailableVersions(): Promise<string[]> {
let rest: restm.RestClient = new restm.RestClient('setup-go');
let tags: IGoRef[] =
(await rest.get<IGoRef[]>(
'https://api.github.com/repos/golang/go/git/refs/tags'
)).result || [];
(await rest.get<IGoRef[]>('https://golang.org/dl/?mode=json&include=all'))
.result || [];
return tags
.filter(tag => tag.ref.match(/go\d+\.[\w\.]+/g))
.map(tag => tag.ref.replace('refs/tags/go', ''));
return tags.map(tag => tag.version.replace('go', ''));
}
async function getPossibleVersions(version: string): Promise<string[]> {