Skip to content

Commit 646f0f0

Browse files
committed
fix: do not rely on google anymore, use github API
It seems google blacklists calls coming from github. Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent f55dfcf commit 646f0f0

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ jobs:
5252
test:
5353
strategy:
5454
matrix:
55-
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, tip]
55+
go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x, tip]
5656
os: [ubuntu-latest, windows-latest, macos-latest]
5757

5858
runs-on: ${{ matrix.os }}
5959

6060
steps:
6161
- name: Setup go
6262
run: |
63-
curl -sL https://raw.githubusercontent.com/maxatome/install-go/v3.7/install-go.pl |
63+
curl -sL https://raw.githubusercontent.com/maxatome/install-go/v3.8/install-go.pl |
6464
perl - ${{ matrix.go-version }} $HOME/go
6565
6666
- name: Checkout code

install-go.pl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ sub resolve_target
176176
$target = $1;
177177

178178
$vreg = quotemeta($target) . '(?:\.([0-9]+))?';
179-
$vreg = qr/^go$vreg\z/;
179+
$vreg = qr,^refs/tags/go$vreg\z,;
180180

181181
$last_minor = -1;
182182
}
@@ -185,27 +185,35 @@ sub resolve_target
185185
die "Bad target $target, should be 1.12 or 1.12.1 or 1.12.x or tip\n"
186186
}
187187

188-
my $r = http_get('https://go.googlesource.com/go/+refs/tags?format=JSON');
188+
my $r = http_get('https://api.github.com/repos/golang/go/git/matching-refs/tags');
189189
$r->{success} or die "Cannot retrieve tags: $r->{status} $r->{reason}\n$r->{content}\n";
190190

191-
my $versions = decode_json($r->{content} =~ s/^[^{]+//r);
191+
my $tags = decode_json($r->{content});
192192

193193
my $found;
194194
if (defined $vreg)
195195
{
196-
foreach (keys %$versions)
196+
foreach (@$tags)
197197
{
198-
if (/$vreg/ and $last_minor < ($1 // 0))
198+
if ($_->{ref} =~ /$vreg/ and $last_minor < ($1 // 0))
199199
{
200-
$last_minor = $1;
200+
$last_minor = $1 // 0;
201201
$found = 1;
202202
}
203203
}
204204
}
205205
else
206206
{
207207
# exact match expected
208-
$found = exists $versions->{"go$target"};
208+
my $match = "refs/tags/go$target";
209+
foreach (@$tags)
210+
{
211+
if ($_->{ref} eq $match)
212+
{
213+
$found = 1;
214+
last;
215+
}
216+
}
209217
}
210218

211219
$found or die "Version $target not found\n";

0 commit comments

Comments
 (0)