diff --git a/cmd/release/main.go b/cmd/release/main.go index d8058a810..c28cc8209 100644 --- a/cmd/release/main.go +++ b/cmd/release/main.go @@ -220,10 +220,12 @@ func (c *command) calculateNewReleasePlugins(currentRelease *release.PluginRelea URL: downloadURL, LastUpdated: now, Status: status, + Dependencies: pluginDependencies(plugin), }) } else { log.Printf("plugin %s:%s unchanged", pluginRelease.PluginName, pluginRelease.PluginVersion) pluginRelease.Status = release.StatusExisting + pluginRelease.Dependencies = pluginDependencies(plugin) existingPlugins = append(existingPlugins, pluginRelease) } return nil @@ -242,6 +244,21 @@ func (c *command) calculateNewReleasePlugins(currentRelease *release.PluginRelea return plugins, nil } +func pluginDependencies(plugin *plugin.Plugin) []string { + if len(plugin.Deps) == 0 { + return nil + } + deps := make([]string, len(plugin.Deps)) + for i, dep := range plugin.Deps { + if dep.Revision != 0 { + log.Fatalf("unsupported plugin dependency revision: %v", dep.Revision) + } + deps[i] = dep.Plugin + } + sort.Strings(deps) + return deps +} + func (c *command) loadMinisignPublicKeyFromFileOrPrivateKey(privateKey minisign.PrivateKey) (minisign.PublicKey, error) { var publicKey minisign.PublicKey if c.minisignPublicKey != "" { diff --git a/internal/release/release.go b/internal/release/release.go index 5f8f68a6c..da5416fa0 100644 --- a/internal/release/release.go +++ b/internal/release/release.go @@ -39,6 +39,7 @@ type PluginRelease struct { URL string `json:"url"` // URL to GitHub release zip file for the plugin - i.e. https://github.com/bufbuild/plugins/releases/download/20221121.1/bufbuild-connect-go-v1.1.0.zip LastUpdated time.Time `json:"last_updated"` Status Status `json:"-"` + Dependencies []string `json:"dependencies,omitempty"` // direct dependencies on other plugins } // CalculateDigest will calculate the sha256 digest of the given file.