auto detect go version is causing some failures
For example: https://github.com/wolfi-dev/os/actions/runs/7927220529/job/21643258067?pr=13149
```
2024/02/16 07:10:36 WARN go: helm.sh/helm/v3@v3.14.1 requires go@1.21, but 1.20 is requested
2024/02/16 07:10:36 ERRO ERROR: failed to build package. the build environment has been preserved:
2024/02/16 07:10:36 INFO workspace dir: /tmp/melange-workspace-2320030291
2024/02/16 07:10:36 INFO guest dir: /tmp/melange-guest-1988135187
2024/02/16 07:10:36 INFO error during command execution: failed to build package: unable to run pipeline: exit status 1
make[1]: *** [Makefile:143: packages/x86_64/helm-push-0.10.4-r2.apk] Error 1
```
`helm-push` is building in melange with go-1.22 which is the latest release.
gobump will [auto detect](https://github.com/chainguard-dev/gobump/blob/d7faf41b0523afab7ac3706722120fb6e09ddc8c/pkg/update/update.go#L76-L84) the go version based on the upstream go mod file, which in this case is [1.20](https://github.com/chartmuseum/helm-push/blob/1678e259cddde8798a7d27db2fca6b9faba13552/go.mod#L3) however that causes a build failure.
For kicks locally I modified the wolfi [pipeline/go/bump.yaml](https://github.com/wolfi-dev/os/tree/main/pipelines/go/bump.yaml) to detect the go version from the version of go being used to perform the build
```
# if ${{inputs.go-version}} is not set, we use the go version of the current environment
if [ -z "${{inputs.go-version}}" ]; then
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
else
GO_VERSION=${{inputs.go-version}}
fi
# We use the --tidy flag to run go mod tidy before and after in some cases (if old versions of go are used, we need to update the go.mod format)
gobump --packages "${{inputs.deps}}" --replaces "${{inputs.replaces}}" --tidy=${{inputs.tidy}} --show-diff=${{inputs.show-diff}} --go-version=${GO_VERSION} --compat=${{inputs.tidy-compat}}
```
And this worked. I wonder if go bump should use the go version from the build environment?
关闭于 2024-02-26 1 条评论