From 0475871171b9798a910d4397d35a4023cf8c8011 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 13:56:53 +0200 Subject: [PATCH] Port recent improvements done in the 'github-pr-resource' pipeline Among which, a Go required version is inferred as 1.x.0, and a Go toolchain version hint of 1.x.y is updated with the actual Go version used for building the code. --- ci/settings.yml | 21 +++++++++++++-------- go.mod | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ci/settings.yml b/ci/settings.yml index 74f4b7f..c54f7fd 100644 --- a/ci/settings.yml +++ b/ci/settings.yml @@ -121,7 +121,7 @@ jobs: type: registry-image source: repository: ${DOCKERHUB_REPOSITORY} - tag: "$(< version/number)" + tag: "$(< version/number)" \`\`\` EOF params: @@ -159,18 +159,22 @@ jobs: | xargs -0 -I{} cp -a {} "repo-bumped" cd "repo-bumped" || exit 115 - awk '/^go /{print $2}' go.mod > ../golang-info/previous-version + awk '/^toolchain /{sub(/go/,"",$2); print $2}' go.mod \ + > ../golang-info/previous-version + ( set -x - go_version=$( - go version \ - | awk '{sub(/go/,"",$3); sub(/\.[[:digit:]]+$/,"",$3); print $3}' - ) - sed -i -Ee "s/^go [[:digit:].]+\$/go ${go_version}/" go.mod + toolchain_version=$(go version | awk '{print $3}') + go_version=${toolchain_version#"go"} + inferred_go_min_version="${go_version%.*}.0" + sed -i -Ee "s/^go [[:digit:].]+\$/go ${inferred_go_min_version}/" go.mod + sed -i -Ee "s/^toolchain go[[:digit:].]+\$/toolchain ${toolchain_version}/" go.mod go get -t -u ./... go mod tidy - echo "${go_version}" > ../golang-info/version + echo "${toolchain_version}" > ../golang-info/toolchain-version + echo "${go_version}" > ../golang-info/version + echo "${inferred_go_min_version}" > ../golang-info/min-version ) - task: build-docker-image @@ -186,6 +190,7 @@ jobs: caches: [ path: cache ] run: { path: build } params: + DEBUG: true IMAGE_ARG_golang: golang-alpine/image.tar IMAGE_ARG_alpine: alpine-latest/image.tar output_mapping: diff --git a/go.mod b/go.mod index 9a66567..2bddf15 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module gstack.io/concourse/keyval-resource -go 1.22 +go 1.22.0 + +toolchain go1.22.3 require ( github.com/google/uuid v1.6.0