Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
- name: Calculate changed plugins and set PLUGINS env var from last successful commit push
if: ${{ inputs.plugins == '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fetch_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
- name: Get buf version
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
- name: Calculate changed plugins and set PLUGINS env var from base branch
if: ${{ inputs.plugins == '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
- name: Create Release
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/restore-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
- name: Restore Release
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version-file: 'go.mod'
check-latest: true
# uses https://cloud.google.com/iam/docs/workload-identity-federation to
# swap a GitHub OIDC token for GCP service account credentials, allowing
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ linters:
- gosec
- prealloc
path: _test\.go
# internal/plugin predates this rule; renaming would be disruptive
- linters:
- revive
path: internal/plugin/
text: "var-naming: avoid package names"
formatters:
enable:
- gci
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DOCKER_BUILD_EXTRA_ARGS ?=
DOCKER_BUILDER := bufbuild-plugins
DOCKER_CACHE_DIR ?= $(TMP)/dockercache
GO ?= go
GOLANGCI_LINT_VERSION ?= v2.8.0
GOLANGCI_LINT_VERSION ?= v2.9.0
GOLANGCI_LINT := $(TMP)/golangci-lint-$(GOLANGCI_LINT_VERSION)

GO_TEST_FLAGS ?= -race -count=1
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bufbuild/plugins

go 1.25.0
go 1.26.0

require (
aead.dev/minisign v0.3.0
Expand Down
18 changes: 8 additions & 10 deletions internal/cmd/release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ func (c *command) calculateNewReleasePlugins(ctx context.Context, currentRelease
return nil, nil
}

plugins := make([]release.PluginRelease, 0, len(newPlugins)+len(existingPlugins))
plugins = append(plugins, newPlugins...)
plugins = append(plugins, existingPlugins...)
plugins := slices.Concat(newPlugins, existingPlugins)
sortPluginsByNameVersion(plugins)
return plugins, nil
}
Expand Down Expand Up @@ -286,20 +284,20 @@ func sortPluginsByNameVersion(plugins []release.PluginRelease) {
}

func (c *command) createRelease(ctx context.Context, client *release.Client, releaseName string, plugins []release.PluginRelease, tmpDir string, privateKey minisign.PrivateKey) error {
releaseBody, err := c.createReleaseBody(releaseName, plugins, privateKey)
releaseBody, err := c.createReleaseBody(releaseName, plugins, privateKey) //nolint:staticcheck // SA4006 false positive with Go 1.26 new(value)
if err != nil {
return err
}
// Create GitHub release
repositoryReleaseParams := &github.RepositoryRelease{
TagName: github.Ptr(releaseName),
Name: github.Ptr(releaseName),
Body: github.Ptr(releaseBody),
TagName: new(releaseName),
Name: new(releaseName),
Body: new(releaseBody),
// Start release as a draft until all assets are uploaded
Draft: github.Ptr(true),
Draft: new(true),
}
if c.githubCommit != "" {
repositoryReleaseParams.TargetCommitish = github.Ptr(c.githubCommit)
repositoryReleaseParams.TargetCommitish = new(c.githubCommit)
}
repositoryRelease, err := client.CreateRelease(ctx, c.githubReleaseOwner, release.GithubRepoPlugins, repositoryReleaseParams)
if err != nil {
Expand All @@ -319,7 +317,7 @@ func (c *command) createRelease(ctx context.Context, client *release.Client, rel
}
// Publish release
if _, err := client.EditRelease(ctx, c.githubReleaseOwner, release.GithubRepoPlugins, repositoryRelease.GetID(), &github.RepositoryRelease{
Draft: github.Ptr(false),
Draft: new(false),
}); err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/cmd/restore-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"log"
"os"
"os/exec"
"slices"
"strings"

"buf.build/go/interrupt"
Expand Down Expand Up @@ -111,9 +112,7 @@ func pushImage(ctx context.Context, name string) error {
}

func dockerCmd(ctx context.Context, command string, args ...string) *exec.Cmd {
commandArgs := make([]string, 0, len(args)+1)
commandArgs = append(commandArgs, command)
commandArgs = append(commandArgs, args...)
commandArgs := slices.Concat([]string{command}, args)
cmd := exec.CommandContext(ctx, "docker", commandArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down
3 changes: 1 addition & 2 deletions internal/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func Walk(dir string, f func(plugin *Plugin) error) error {
// sortByDependencyOrder sorts the passed in plugins such that each dependency comes before a plugin with dependencies.
func sortByDependencyOrder(original []*Plugin) ([]*Plugin, error) {
// Make a defensive copy of the original list
plugins := make([]*Plugin, len(original))
copy(plugins, original)
plugins := slices.Clone(original)
resolved := make([]*Plugin, 0, len(plugins))
resolvedMap := make(map[string]struct{}, len(plugins))
for len(plugins) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions internal/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"log"
"os"
"slices"
"strings"
"time"
)
Expand Down Expand Up @@ -68,8 +69,7 @@ func CalculateDigest(path string) (string, error) {
// The original slice is unmodified - it returns a copy in sorted order, or an error if there is a cycle or unmet dependency.
func SortReleasesInDependencyOrder(original []PluginRelease) ([]PluginRelease, error) {
// Make a defensive copy of the original list
plugins := make([]PluginRelease, len(original))
copy(plugins, original)
plugins := slices.Clone(original)
resolved := make([]PluginRelease, 0, len(plugins))
resolvedMap := make(map[string]struct{}, len(plugins))
for len(plugins) > 0 {
Expand Down
5 changes: 1 addition & 4 deletions tests/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,7 @@ func createProtocGenPlugin(t *testing.T, basedir string, plugin *plugin.Plugin)
if len(fields) != 3 {
return fmt.Errorf("invalid plugin name: %v", plugin.Name)
}
dockerOrg := os.Getenv("DOCKER_ORG")
if len(dockerOrg) == 0 {
dockerOrg = "bufbuild"
}
dockerOrg := cmp.Or(os.Getenv("DOCKER_ORG"), "bufbuild")
return protocGenPluginTemplate.Execute(protocGenPlugin, map[string]any{
"ImageName": fmt.Sprintf("%s/plugins-%s-%s", dockerOrg, fields[1], fields[2]),
"Version": plugin.PluginVersion,
Expand Down