From ba536cb4cb01741217127658c2880d5009ef6d83 Mon Sep 17 00:00:00 2001 From: Grivn <56754250+Grivn@users.noreply.github.com> Date: Fri, 16 Oct 2026 00:23:08 +0800 Subject: [PATCH 1/3] build: install gfmrun from source on the host platform --- scripts/build.go | 55 +++++------------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/scripts/build.go b/scripts/build.go index 689f9540ed..1f3f304a4c 100644 --- a/scripts/build.go +++ b/scripts/build.go @@ -8,16 +8,12 @@ import ( "context" "errors" "fmt" - "io" "log" "math" - "net/http" - "net/url" "os" "os/exec" "path/filepath" "regexp" - "runtime" "strings" "time" @@ -195,43 +191,6 @@ func runCmd(ctx context.Context, arg string, args ...string) error { return cmd.Run() } -func downloadFile(src, dest string, dirPerm, perm os.FileMode) error { - req, err := http.NewRequest(http.MethodGet, src, nil) - if err != nil { - return err - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return err - } - - defer resp.Body.Close() - - if resp.StatusCode >= 300 { - return fmt.Errorf("download file from %[2]s into %[3]s: response %[1]v", resp.StatusCode, src, dest) - } - - if err := os.MkdirAll(filepath.Dir(dest), dirPerm); err != nil { - return err - } - - out, err := os.Create(dest) - if err != nil { - return err - } - - if _, err := io.Copy(out, resp.Body); err != nil { - return err - } - - if err := out.Close(); err != nil { - return err - } - - return os.Chmod(dest, perm) -} - func VetActionFunc(ctx context.Context, cmd *cli.Command) error { return runCmd(ctx, "go", "vet", cmd.String("top-dir")+"/...") } @@ -569,17 +528,13 @@ func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error { return nil } - gfmrunURL, err := url.Parse( - fmt.Sprintf( - "https://github.com/urfave/gfmrun/releases/download/%[1]s/gfmrun-%[2]s-%[3]s-%[1]s", - gfmrunVersion, runtime.GOOS, runtime.GOARCH, - ), - ) - if err != nil { + if err := os.Setenv("GOBIN", filepath.Dir(gfmrunExe)); err != nil { return err } - - return downloadFile(gfmrunURL.String(), gfmrunExe, 0o755, 0o755) + return runCmd(ctx, "go", "install", + "-ldflags=-X github.com/urfave/gfmrun.VersionString="+gfmrunVersion, + "github.com/urfave/gfmrun/cmd/gfmrun@"+gfmrunVersion, + ) } func EnsureMkdocsActionFunc(ctx context.Context, cmd *cli.Command) error { From a7e1b40bd27a959512bae3fd6ac9e7ce69168035 Mon Sep 17 00:00:00 2001 From: Grivn <56754250+Grivn@users.noreply.github.com> Date: Fri, 16 Oct 2026 00:29:39 +0800 Subject: [PATCH 2/3] build: resolve the gfmrun install directory before changing directories --- scripts/build.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build.go b/scripts/build.go index 1f3f304a4c..b1ff4e6518 100644 --- a/scripts/build.go +++ b/scripts/build.go @@ -517,7 +517,10 @@ func EnsureGoimportsActionFunc(ctx context.Context, cmd *cli.Command) error { } func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error { - topDir := cmd.String("top-dir") + topDir, err := filepath.Abs(cmd.String("top-dir")) + if err != nil { + return err + } gfmrunExe := filepath.Join(topDir, ".local/bin/gfmrun") if err := os.Chdir(topDir); err != nil { From 62a7d2ed27cf3df0a44b1956a80902e7e8439329 Mon Sep 17 00:00:00 2001 From: Grivn <56754250+Grivn@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:02:33 +0800 Subject: [PATCH 3/3] build: bump gfmrun to v1.3.3 --- scripts/build.go | 62 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/scripts/build.go b/scripts/build.go index b1ff4e6518..d2f0cc637e 100644 --- a/scripts/build.go +++ b/scripts/build.go @@ -8,12 +8,16 @@ import ( "context" "errors" "fmt" + "io" "log" "math" + "net/http" + "net/url" "os" "os/exec" "path/filepath" "regexp" + "runtime" "strings" "time" @@ -25,7 +29,7 @@ const ( goodNewsEmoji = "✨" checksPassedEmoji = "✅" - gfmrunVersion = "v1.3.0" + gfmrunVersion = "v1.3.3" v3diffWarning = ` # The unified diff above indicates that the public API surface area @@ -191,6 +195,43 @@ func runCmd(ctx context.Context, arg string, args ...string) error { return cmd.Run() } +func downloadFile(src, dest string, dirPerm, perm os.FileMode) error { + req, err := http.NewRequest(http.MethodGet, src, nil) + if err != nil { + return err + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode >= 300 { + return fmt.Errorf("download file from %[2]s into %[3]s: response %[1]v", resp.StatusCode, src, dest) + } + + if err := os.MkdirAll(filepath.Dir(dest), dirPerm); err != nil { + return err + } + + out, err := os.Create(dest) + if err != nil { + return err + } + + if _, err := io.Copy(out, resp.Body); err != nil { + return err + } + + if err := out.Close(); err != nil { + return err + } + + return os.Chmod(dest, perm) +} + func VetActionFunc(ctx context.Context, cmd *cli.Command) error { return runCmd(ctx, "go", "vet", cmd.String("top-dir")+"/...") } @@ -517,10 +558,7 @@ func EnsureGoimportsActionFunc(ctx context.Context, cmd *cli.Command) error { } func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error { - topDir, err := filepath.Abs(cmd.String("top-dir")) - if err != nil { - return err - } + topDir := cmd.String("top-dir") gfmrunExe := filepath.Join(topDir, ".local/bin/gfmrun") if err := os.Chdir(topDir); err != nil { @@ -531,13 +569,17 @@ func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error { return nil } - if err := os.Setenv("GOBIN", filepath.Dir(gfmrunExe)); err != nil { + gfmrunURL, err := url.Parse( + fmt.Sprintf( + "https://github.com/urfave/gfmrun/releases/download/%[1]s/gfmrun-%[2]s-%[3]s-%[1]s", + gfmrunVersion, runtime.GOOS, runtime.GOARCH, + ), + ) + if err != nil { return err } - return runCmd(ctx, "go", "install", - "-ldflags=-X github.com/urfave/gfmrun.VersionString="+gfmrunVersion, - "github.com/urfave/gfmrun/cmd/gfmrun@"+gfmrunVersion, - ) + + return downloadFile(gfmrunURL.String(), gfmrunExe, 0o755, 0o755) } func EnsureMkdocsActionFunc(ctx context.Context, cmd *cli.Command) error {