feat(cli): rewrite plugin publish to send tar.zst archive
This commit is contained in:
parent
a827cda37a
commit
e5b27f5a65
@ -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
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user