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() { Function Get-ProtobufTag() {
$releases = 'https://github.com/protocolbuffers/protobuf/releases'
if("$protobuf_tag" -eq "latest") { 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 { } else {
try { try {
[net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag") $protobuf_tag = $protobuf_tag -replace '^v', ''
$req.Method = "HEAD" [net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/v$protobuf_tag")
$request.Method = "HEAD"
[net.httpWebResponse] $response = $request.getResponse() [net.httpWebResponse] $response = $request.getResponse()
$response.Close() $response.Close()
$protobuf_tag = "v$protobuf_tag" $protobuf_tag = "v$protobuf_tag"
} catch { } 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 return $protobuf_tag