chainguard-dev / gobump

Go tool to declaratively bump dependencies.
Apache License 2.0
7 stars 11 forks source link

Support multi-line #2

Open mamccorm opened 11 months ago

mamccorm commented 11 months ago

Rather than defining each package on a single line, it'd be nice to be able to split across multiple lines. For example:

  - uses: go/bump
    with:
      deps: |
        github.com/elazarl/goproxy@v0.0.0-20231117061959-7cc037d33fb5
        github.com/go-jose/go-jose/v3@v3.0.1
        go.opentelemetry.io/otel@v1.21.0
        go.opentelemetry.io/otel/trace@v1.21.0
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.46.0
        go.opentelemetry.io/otel/sdk@v1.21.0

This doesn't work as of today, and results in:

  aarch64   | Usage: gobump -packages=<package@version>,...
2023/12/19 10:19:18 ERROR: failed to build package. the build environment has been preserved:
hectorj2f commented 11 months ago

@mamccorm there is a similar conversation here: https://chainguard-dev.slack.com/archives/C0636FTRFED/p1702935348910069. We are working on these and other improvements ;).

hectorj2f commented 11 months ago

Thanks for opening the issue, we want to change the single liner to accept a list (that'd be ideal). That would help our future automation of these bumps and the readability of the package def.

debasishbsws commented 10 months ago

Hey @hectorj2f as for multiline go bump can't we use the YAML multiline string format?

with this bellow change

index f3b6081..e3d90a9 100644
--- a/main.go
+++ b/main.go
@@ -29,6 +29,10 @@ func main() {
        replaces = strings.Split(*replacesFlag, " ")
    }

+   if strings.HasSuffix(*packagesFlag, "\n") {
+       *packagesFlag = (*packagesFlag)[:len(*packagesFlag)-1]
+   }
+
    packages := strings.Split(*packagesFlag, " ")
    pkgVersions := []pkgVersion{}
    for _, pkg := range packages {

we can use go/bump as

  - uses: go/bump
    with:
      go-version: "1.21"
      deps: >
        github.com/containerd/containerd@v1.7.11
        golang.org/x/crypto@v0.17.0
        github.com/go-jose/go-jose/v3@v3.0.1
        google.golang.org/grpc@v1.56.3
        github.com/docker/docker@v24.0.7

I know it is not the best approach. and it would be much better if we could have a list of packages instead of a single string.

hectorj2f commented 10 months ago

@debasishbsws Yes, the idea is take over this issue during next week. We'll try to find an optimal solution for anyone reading the deps and any of our automated tools relying on this data.