Fix protoc support on Windows

This commit is contained in:
Shivam Mathur 2022-12-19 06:57:44 +05:30
parent 189e8e6ec0
commit 04b2ed5b3e
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -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