Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .exe extension for buf download to prevent 404 #2841

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use DownloadArchiveOptions instead
Signed-off-by: Ludvig Liljenberg <[email protected]>
  • Loading branch information
ludfjig committed Jul 27, 2023
commit 7e7ef290c880d5b63abd25c46f6594778af8e513
42 changes: 25 additions & 17 deletions mage/setup/tools.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package setup

import (
"fmt"
"os/exec"
"runtime"

Expand Down Expand Up @@ -45,26 +44,35 @@ func EnsureBufBuild() {
if ok, _ := pkg.IsCommandAvailable("buf", "--version", "1.11.0"); ok {
return
}
opts := downloads.DownloadOptions{
UrlTemplate: "https://github.com/bufbuild/buf/releases/download/v{{.VERSION}}/buf-{{.GOOS}}-{{.GOARCH}}{{.EXT}}",
Name: "buf",
Version: "1.11.0",
OsReplacement: map[string]string{
"darwin": "Darwin",
"linux": "Linux",
"windows": "Windows",
},
ArchReplacement: map[string]string{
"amd64": "x86_64",
},
}

target := "buf-{{.GOOS}}-{{.GOARCH}}{{.EXT}}"
if runtime.GOOS == "windows" {
opts.Ext = ".exe"
fmt.Print("yes")
target = "buf-{{.GOOS}}-{{.GOARCH}}.exe"
}

err := downloads.DownloadToGopathBin(opts)
opts := archive.DownloadArchiveOptions{
DownloadOptions: downloads.DownloadOptions{
UrlTemplate: "https://github.com/bufbuild/buf/releases/download/v{{.VERSION}}/buf-{{.GOOS}}-{{.GOARCH}}{{.EXT}}",
Name: "buf",
Version: "1.11.0",
OsReplacement: map[string]string{
"darwin": "Darwin",
"linux": "Linux",
"windows": "Windows",
},
ArchReplacement: map[string]string{
"amd64": "x86_64",
},
// empty hook to override default archive extraction
Hook: func(archivePath string) (string, error) { return archivePath, nil },
},
ArchiveExtensions: map[string]string{
"windows": ".exe",
},
TargetFileTemplate: target,
}

err := archive.DownloadToGopathBin(opts)
mgx.Must(err)
}

Expand Down
Loading