Skip to content

Commit 669355e

Browse files
v1vmergify[bot]
authored andcommitted
updatecli: converge both golang versions together (#634)
Co-authored-by: Dimitrios Liappis <dimitrios.liappis@gmail.com> (cherry picked from commit 1b40a6d) # Conflicts: # .github/updatecli.d/bump-go-version.sh
1 parent 26a6924 commit 669355e

File tree

4 files changed

+62
-181
lines changed

4 files changed

+62
-181
lines changed

.github/updatecli.d/bump-go-microsoft-version.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/usr/bin/env bash
22
#
3-
# Given the Golang release version this script will bump the version.
3+
# Given the Microsoft Golang release version this script will bump the version.
44
#
55
# This script is executed by the automation we are putting in place
66
#
7-
# NOTE: sha256 is retrieved from https://pkg.go.dev/golang.org/x/website/internal/dl?utm_source=godoc
7+
# NOTE:
8+
# * sha256 is retrieved from https://pkg.go.dev/golang.org/x/website/internal/dl?utm_source=godoc
9+
# * sha256 is retrieved from https://aka.ms/golang/release/latest/go${MAJOR_MINOR_PATCH_VERSION}.assets.json
810
#
911
# Parameters:
10-
# $1 -> the Golang release version to be bumped. Mandatory.
12+
# $1 -> the Microsoft Golang release version to be bumped. Mandatory.
1113
#
1214
set -euo pipefail
1315
MSG="parameter missing."
@@ -19,28 +21,34 @@ else
1921
SED="sed -i"
2022
fi
2123

22-
MAJOR_MINOR_VERSION=$(echo "$GO_RELEASE_VERSION" | sed -E -e "s#([0-9]+\.[0-9]+).*#\1#g")
24+
# Process the GO_RELEASE_VERSION to extract major, minor, patch and security versions
25+
MAJOR_MINOR_PATCH_VERSION=${GO_RELEASE_VERSION%-*}
26+
SECURITY_VERSION="-${GO_RELEASE_VERSION##*-}"
27+
28+
# Gather golang/go sha256 values
2329
GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl/\?mode\=json | jq -r ".[] | select( .version | contains(\"go${GO_RELEASE_VERSION}\")) | .files[] | select (.filename | contains(\"go${GO_RELEASE_VERSION}.linux-arm64.tar.gz\")) | .sha256")
2430
GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl/\?mode\=json | jq -r ".[] | select( .version | contains(\"go${GO_RELEASE_VERSION}\")) | .files[] | select (.filename | contains(\"go${GO_RELEASE_VERSION}.linux-amd64.tar.gz\")) | .sha256")
2531

2632
# Gather microsoft/go sha256 values
33+
<<<<<<< HEAD:.github/updatecli.d/bump-go-release-version.sh
2734
MSFT_DOWNLOAD_METADATA=$(curl -s -L https://aka.ms/golang/release/latest/go${GO_RELEASE_VERSION}.assets.json)
35+
=======
36+
MSFT_DOWNLOAD_METADATA=$(curl -s -L https://aka.ms/golang/release/latest/go${MAJOR_MINOR_PATCH_VERSION}.assets.json)
37+
>>>>>>> 1b40a6d (updatecli: converge both golang versions together (#634)):.github/updatecli.d/bump-go-version.sh
2838
MSFT_DOWNLOAD_SHA256_ARM=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"arm64\") | .sha256")
2939
MSFT_DOWNLOAD_SHA256_AMD=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"amd64\") | .sha256")
3040

3141
## As long as https://golang.org/dl/?mode=json supports only 2 major versions
3242
## and there is a new major release, then it's required to parse https://golang.org/dl
3343
## see https://github.com/elastic/golang-crossbuild/pull/389/commits/d0af04f97a2381630ea5e8da5a99f50cf27856a0
3444
if [ -z "$GOLANG_DOWNLOAD_SHA256_ARM" ] ; then
35-
GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl | grep go${GO_RELEASE_VERSION}.linux-arm64.tar.gz -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
45+
GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl | grep "go${MAJOR_MINOR_PATCH_VERSION}.linux-arm64.tar.gz" -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
3646
fi
3747

3848
if [ -z "$GOLANG_DOWNLOAD_SHA256_AMD" ] ; then
39-
GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl | grep go${GO_RELEASE_VERSION}.linux-amd64.tar.gz -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
49+
GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl | grep "go${MAJOR_MINOR_PATCH_VERSION}.linux-amd64.tar.gz" -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
4050
fi
4151

42-
echo "Update go version ${GO_RELEASE_VERSION}"
43-
4452
find "go" -type f -name Dockerfile.tmpl -print0 |
4553
while IFS= read -r -d '' line; do
4654
if echo "$line" | grep -q 'arm' ; then
@@ -51,3 +59,11 @@ find "go" -type f -name Dockerfile.tmpl -print0 |
5159
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_AMD}#g" "$line"
5260
fi
5361
done
62+
63+
if git diff --quiet ; then
64+
# No modifications – exit successfully but keep stdout empty to that updatecli is happy
65+
exit 0
66+
else
67+
echo "Update Go version ${GO_RELEASE_VERSION}"
68+
git --no-pager diff
69+
fi

.github/updatecli.d/bump-golang.yml

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ scms:
1616

1717
actions:
1818
default:
19-
title: '[Automation] Bump Golang version to {{ source "latestGoVersion" }}'
19+
title: '[Automation] Bump Golang version to {{ source "latestMicrosoftGoVersion" }}'
2020
kind: github/pullrequest
2121
scmid: githubConfig
2222
spec:
23-
automerge: true
23+
automerge: false
2424
labels:
2525
- automation
2626
- dependencies
2727
- backport-skip
2828
description: |
29-
See [changelog](https://github.com/golang/go/issues?q=milestone%3AGo{{ source "latestGoVersion" }}+label%3ACherryPickApproved) for {{ source "latestGoVersion" }}
29+
See [changelog](https://github.com/golang/go/issues?q=milestone%3AGo{{ source "golangVersion" }}+label%3ACherryPickApproved) for {{ source "golangVersion" }}
3030
3131
sources:
3232
minor:
@@ -39,75 +39,78 @@ sources:
3939
spec:
4040
command: echo {{ requiredEnv "GO_MINOR" }}
4141

42-
latestGoVersion:
43-
name: Get Latest Go Release
42+
latestMicrosoftGoVersion:
43+
name: Get Latest Microsoft Go Release
4444
kind: githubrelease
4545
dependson:
4646
- minor
4747
transformers:
48-
- trimprefix: go
48+
- trimprefix: v
4949
spec:
50-
owner: golang
50+
owner: microsoft
5151
repository: go
5252
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
5353
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
5454
versionfilter:
5555
kind: regex
56-
pattern: go1\.{{ source "minor" }}(\.(\d*))?$
56+
pattern: v1\.{{ source "minor" }}\.(\d*)(-\d*)$
57+
58+
golangVersion:
59+
# NOTE: FIPS images need the Microsoft version.
60+
name: Get the Microsoft version of Golang, as it comes out a little later
61+
dependson:
62+
- latestMicrosoftGoVersion
63+
kind: shell
64+
transformers:
65+
- findsubmatch:
66+
pattern: '^(\d+.\d+.\d+)-(\d+)'
67+
captureindex: 1
68+
spec:
69+
command: echo {{ source "latestMicrosoftGoVersion" }}
5770

5871
conditions:
5972
dockerTag:
60-
name: Is docker image golang:{{ source "latestGoVersion" }} published
73+
name: Is docker image golang:{{ source "golangVersion" }} published
6174
kind: dockerimage
6275
spec:
6376
image: golang
64-
tag: '{{ source "latestGoVersion" }}'
65-
sourceid: latestGoVersion
66-
## As long as there is a bug see https://github.com/updatecli/updatecli/issues/1849
67-
## Let's use the shell kind rather than the file kind.
68-
## When fixed then uncomment the code and remove is-already-updated
69-
# is:
70-
# name: Is version '{{ source "latestGoVersion" }}' not updated in 'go/Makefile.common'?
71-
# disablesourceinput: true
72-
# kind: file
73-
# spec:
74-
# file: go/Makefile.common
75-
# line: 5
76-
# content: VERSION := {{ source `latestGoVersion` }}
77-
# failwhen: true
78-
is-already-updated:
79-
name: Is version '{{ source "latestGoVersion" }}' not updated in 'go/Makefile.common'?
77+
tag: '{{ source "golangVersion" }}'
78+
sourceid: golangVersion
79+
is:
80+
name: Is version '{{ source "golangVersion" }}' not updated in 'go/Makefile.common'?
8081
disablesourceinput: true
81-
kind: shell
82+
kind: file
8283
spec:
83-
command: grep 'VERSION := {{ source `latestGoVersion` }}' go/Makefile.common && exit 1 || exit 0
84-
failwhen: false
84+
file: go/Makefile.common
85+
line: 5
86+
content: VERSION := {{ source `golangVersion` }}
87+
failwhen: true
8588

8689
targets:
8790
update-go-version:
8891
name: "Update .go-version"
89-
sourceid: latestGoVersion
92+
sourceid: golangVersion
9093
scmid: githubConfig
9194
kind: file
9295
spec:
93-
content: '{{ source "latestGoVersion" }}'
96+
content: '{{ source "golangVersion" }}'
9497
file: .go-version
9598
matchpattern: '\d+.\d+.\d+'
9699
update-go-makefile.common:
97100
name: "Update go/Makefile.common"
98-
sourceid: latestGoVersion
101+
sourceid: golangVersion
99102
scmid: githubConfig
100103
kind: file
101104
spec:
102-
content: '{{ source "latestGoVersion" }}'
105+
content: '{{ source "golangVersion" }}'
103106
file: go/Makefile.common
104107
matchpattern: '\d+.\d+.\d+'
105108
update-go-versions:
106-
name: 'Update go version {{ source "latestGoVersion" }}'
109+
name: 'Update go version {{ source "latestMicrosoftGoVersion" }}'
107110
kind: shell
108-
sourceid: latestGoVersion
111+
sourceid: latestMicrosoftGoVersion
109112
scmid: githubConfig
110113
spec:
111-
command: .github/updatecli.d/bump-go-release-version.sh
114+
command: .github/updatecli.d/bump-go-version.sh
112115
environments:
113116
- name: PATH

.github/updatecli.d/bump-microsoft.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)