From 04b2ed5b3eea3006ac94e83e89e4882076f80443 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 19 Dec 2022 06:57:44 +0530 Subject: [PATCH] Fix protoc support on Windows --- src/scripts/tools/protoc.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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