diff --git a/src/scripts/tools/protoc.ps1 b/src/scripts/tools/protoc.ps1 index 3b51b2fe..adecad4c 100644 --- a/src/scripts/tools/protoc.ps1 +++ b/src/scripts/tools/protoc.ps1 @@ -1,15 +1,17 @@ Function Get-ProtobufTag() { + $releases = 'https://github.com/protocolbuffers/protobuf/releases' if("$protobuf_tag" -eq "latest") { - $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1 + $protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] } else { try { - [net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag") - $req.Method = "HEAD" + $protobuf_tag = $protobuf_tag -replace '^v', '' + [net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/v$protobuf_tag") + $request.Method = "HEAD" [net.httpWebResponse] $response = $request.getResponse() $response.Close() $protobuf_tag = "v$protobuf_tag" } catch { - $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1 + $protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] } } return $protobuf_tag