Skip to content

Commit abd1b4d

Browse files
authored
updatecli: run bump-golang and bump-go-microsoft independent (#607)
1 parent 87fa2d4 commit abd1b4d

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ echo "Update go version ${GO_RELEASE_VERSION}"
2929

3030
find "go" -type f -name Dockerfile.tmpl -print0 |
3131
while IFS= read -r -d '' line; do
32-
${SED} -E -e "s#(ARG GOLANG_VERSION)=[0-9]+\.[0-9]+(\.[0-9]+)?#\1=${MAJOR_MINOR_PATCH_VERSION}#g" "$line"
32+
${SED} -E -e "s#(ARG SECURITY_VERSION)=.*#\1=${SECURITY_VERSION}#g" "$line"
3333
if echo "$line" | grep -q 'arm' ; then
3434
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_ARM}#g" "$line"
35-
${SED} -E -e "s#(ARG SECURITY_VERSION)=.*#\1=${SECURITY_VERSION}#g" "$line"
3635
else
3736
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_AMD}#g" "$line"
38-
${SED} -E -e "s#(ARG SECURITY_VERSION)=.*#\1=${SECURITY_VERSION}#g" "$line"
3937
fi
4038
done

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl/\?mode\=json | jq
2424
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")
2525

2626
# Gather microsoft/go sha256 values
27-
MSFT_DOWNLOAD_METADATA=$(curl -s -L https://aka.ms/golang/release/latest/go${GO_RELEASE_VERSION}.assets.json)
28-
MSFT_DOWNLOAD_SHA256_ARM=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"arm64\") | .sha256")
29-
MSFT_DOWNLOAD_SHA256_AMD=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"amd64\") | .sha256")
27+
URL=https://aka.ms/golang/release/latest/go${GO_RELEASE_VERSION}.assets.json
28+
if curl -s -L "$URL" > /dev/null ; then
29+
MSFT_DOWNLOAD_METADATA=$(curl -s -L "$URL")
30+
MSFT_DOWNLOAD_SHA256_ARM=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"arm64\") | .sha256")
31+
MSFT_DOWNLOAD_SHA256_AMD=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"amd64\") | .sha256")
32+
# when a new minor then we use `-1`
33+
# then nex security versions will be `-2`, `-3`, etc, see bump-microsoft.yml
34+
SECURITY_VERSION=-1
35+
fi
3036

3137
## As long as https://golang.org/dl/?mode=json supports only 2 major versions
3238
## and there is a new major release, then it's required to parse https://golang.org/dl
@@ -46,9 +52,16 @@ find "go" -type f -name Dockerfile.tmpl -print0 |
4652
${SED} -E -e "s#(ARG GOLANG_VERSION)=[0-9]+\.[0-9]+(\.[0-9]+)?#\1=${GO_RELEASE_VERSION}#g" "$line"
4753
if echo "$line" | grep -q 'arm' ; then
4854
${SED} -E -e "s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\1=${GOLANG_DOWNLOAD_SHA256_ARM}#g" "$line"
49-
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_ARM}#g" "$line"
55+
if [ -n "$MSFT_DOWNLOAD_SHA256_ARM" ]; then
56+
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_ARM}#g" "$line"
57+
fi
5058
else
5159
${SED} -E -e "s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\1=${GOLANG_DOWNLOAD_SHA256_AMD}#g" "$line"
52-
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_AMD}#g" "$line"
60+
if [ -n "$MSFT_DOWNLOAD_SHA256_AMD" ]; then
61+
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_AMD}#g" "$line"
62+
fi
63+
fi
64+
if [ -n "$SECURITY_VERSION" ]; then
65+
${SED} -E -e "s#(ARG SECURITY_VERSION)=.*#\1=${SECURITY_VERSION}#g" "$line"
5366
fi
5467
done

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ conditions:
8282
spec:
8383
command: grep 'VERSION := {{ source `latestGoVersion` }}' go/Makefile.common && exit 1 || exit 0
8484
failwhen: false
85-
is-not-available:
86-
name: Is assets.json available?
87-
kind: file
88-
disablesourceinput: true
89-
spec:
90-
file: https://aka.ms/golang/release/latest/go{{ source `latestGoVersion` }}.assets.json
91-
failwhen: true
9285

9386
targets:
9487
update-go-version:

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,37 @@ sources:
6767
spec:
6868
command: echo {{ source "latestGoVersion" }}
6969

70+
golangVersion:
71+
name: Get golang version
72+
dependson:
73+
- latestGoVersion
74+
kind: shell
75+
transformers:
76+
- findsubmatch:
77+
pattern: '^(\d+.\d+.\d+)-(\d+)'
78+
captureindex: 1
79+
spec:
80+
command: echo {{ source "latestGoVersion" }}
81+
7082
conditions:
71-
is-already-updated:
83+
is-security-already-updated:
7284
name: Is security version '{{ source "securityVersion" }}' not updated in 'go/base/Dockerfile.tmpl'?
7385
disablesourceinput: true
7486
kind: shell
7587
spec:
7688
command: grep 'ARG SECURITY_VERSION={{ source `securityVersion` }}' go/base/Dockerfile.tmpl && exit 1 || exit 0
7789
failwhen: false
7890

91+
# as long as the same golang version then update the security version.
92+
# if a new golang version then .github/updatecli.d/bump-golang.yml will be triggered.
93+
is-golang-available:
94+
name: Is version '{{ source "golangVersion" }}' available in 'go/base/Dockerfile.tmpl'?
95+
disablesourceinput: true
96+
kind: shell
97+
spec:
98+
command: grep 'ARG GOLANG_VERSION={{ source `golangVersion` }}' go/base/Dockerfile.tmpl && exit 0 || exit 1
99+
failwhen: false
100+
79101
targets:
80102
update-go-versions:
81103
name: 'Update go version {{ source "latestGoVersion" }}'

0 commit comments

Comments
 (0)