From e5b27f5a653622c6e5e20f8b2648db5de2667668 Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Wed, 3 Jun 2026 01:33:12 +0800 Subject: [PATCH] feat(cli): rewrite plugin publish to send tar.zst archive --- cmd/ninja/cmd/plugin.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/ninja/cmd/plugin.go b/cmd/ninja/cmd/plugin.go index 338f928..cb39b7c 100644 --- a/cmd/ninja/cmd/plugin.go +++ b/cmd/ninja/cmd/plugin.go @@ -16,6 +16,7 @@ import ( core "git.dev.alexdunmow.com/block/core/plugin" + "git.dev.alexdunmow.com/block/core/cmd/ninja/internal/archive" "git.dev.alexdunmow.com/block/core/cmd/ninja/internal/creds" "git.dev.alexdunmow.com/block/core/cmd/ninja/internal/orchclient" v1 "git.dev.alexdunmow.com/block/core/internal/api/orchestrator/v1" @@ -206,7 +207,7 @@ func newPluginPublishCmd() *cobra.Command { var allowDirty bool cmd := &cobra.Command{ Use: "publish", - Short: "Push the current commit as a new version and notify the registry", + Short: "Build a source archive and publish a new version to the registry", RunE: func(c *cobra.Command, _ []string) error { host, _ := c.Flags().GetString("host") cr, err := creds.Load() @@ -238,14 +239,10 @@ func newPluginPublishCmd() *cobra.Command { } } - tag := "v" + mod.Plugin.Version - if err := runCmd("git", "tag", "-a", tag, "-m", tag); err != nil { - fmt.Fprintf(os.Stderr, "tag %s already exists or could not be created (%v); attempting push\n", tag, err) + archiveBytes, err := archive.BuildSourceArchive(".") + if err != nil { + return fmt.Errorf("build archive: %w", err) } - if err := runCmd("git", "push", "ninja", tag); err != nil { - return fmt.Errorf("git push ninja %s: %w", tag, err) - } - fmt.Printf("Pushed %s to ninja remote\n", tag) ctx := context.Background() pr, err := cli.Reg.GetPlugin(ctx, connect.NewRequest(&v1.GetPluginRequest{ @@ -260,19 +257,19 @@ func newPluginPublishCmd() *cobra.Command { pubResp, err := cli.Pub.PublishVersion(ctx, connect.NewRequest(&v1.PublishVersionRequest{ PluginId: pr.Msg.Plugin.Id, - GitRef: "refs/tags/" + tag, + Version: mod.Plugin.Version, Channel: channel, + Archive: archiveBytes, ReadmeMd: string(readme), ChangelogMd: string(changelog), })) if err != nil { return fmt.Errorf("publish: %w", err) } - fmt.Printf("Published version_id=%s\n", pubResp.Msg.Version.Id) + fmt.Printf("Published %s@%s (%d bytes)\n", mod.Coords(), pubResp.Msg.Version.Version, len(archiveBytes)) for _, w := range pubResp.Msg.Warnings { fmt.Printf(" warning: %s\n", w) } - fmt.Printf(" Archive: %s\n", pubResp.Msg.ArchiveUrl) return nil }, }