mirror of
https://codeberg.org/actions/setup-go.git
synced 2024-01-07 17:16:05 +00:00
use golang-dl release data
This commit is contained in:
parent
595aed780b
commit
21620fff65
10196
__tests__/data/golang-dl.json
Normal file
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
|
@ -43,9 +43,10 @@ describe('installer tests', () => {
|
||||||
|
|
||||||
describe('the latest release of a go version', () => {
|
describe('the latest release of a go version', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nock('https://api.github.com')
|
nock('https://golang.org')
|
||||||
.get('/repos/golang/go/git/refs/tags')
|
.get('/dl/')
|
||||||
.replyWithFile(200, path.join(dataDir, 'golang-tags.json'));
|
.query({mode: 'json', include: 'all'})
|
||||||
|
.replyWithFile(200, path.join(dataDir, 'golang-dl.json'));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -186,10 +186,9 @@ function getLatestVersion(version) {
|
||||||
function getAvailableVersions() {
|
function getAvailableVersions() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let rest = new restm.RestClient('setup-go');
|
let rest = new restm.RestClient('setup-go');
|
||||||
let tags = (yield rest.get('https://api.github.com/repos/golang/go/git/refs/tags')).result || [];
|
let tags = (yield rest.get('https://golang.org/dl/?mode=json&include=all'))
|
||||||
return tags
|
.result || [];
|
||||||
.filter(tag => tag.ref.match(/go\d+\.[\w\.]+/g))
|
return tags.map(tag => tag.version.replace('go', ''));
|
||||||
.map(tag => tag.ref.replace('refs/tags/go', ''));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getPossibleVersions(version) {
|
function getPossibleVersions(version) {
|
||||||
|
|
|
@ -187,19 +187,16 @@ async function getLatestVersion(version: string): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IGoRef {
|
interface IGoRef {
|
||||||
ref: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAvailableVersions(): Promise<string[]> {
|
async function getAvailableVersions(): Promise<string[]> {
|
||||||
let rest: restm.RestClient = new restm.RestClient('setup-go');
|
let rest: restm.RestClient = new restm.RestClient('setup-go');
|
||||||
let tags: IGoRef[] =
|
let tags: IGoRef[] =
|
||||||
(await rest.get<IGoRef[]>(
|
(await rest.get<IGoRef[]>('https://golang.org/dl/?mode=json&include=all'))
|
||||||
'https://api.github.com/repos/golang/go/git/refs/tags'
|
.result || [];
|
||||||
)).result || [];
|
|
||||||
|
|
||||||
return tags
|
return tags.map(tag => tag.version.replace('go', ''));
|
||||||
.filter(tag => tag.ref.match(/go\d+\.[\w\.]+/g))
|
|
||||||
.map(tag => tag.ref.replace('refs/tags/go', ''));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPossibleVersions(version: string): Promise<string[]> {
|
async function getPossibleVersions(version: string): Promise<string[]> {
|
||||||
|
|
Loading…
Reference in a new issue