-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathupdate-go-version.bash
More file actions
41 lines (35 loc) · 1.35 KB
/
update-go-version.bash
File metadata and controls
41 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/env bash
set -e
get_latest_versions() {
curl -s https://go.dev/VERSION?m=text | sed -E -n 's/go([0-9]+\.[0-9]+|\.[0-9]+).*/\1/p'
}
# Extract the current stable version from JSON
current_version=$(grep -A 1 '"label": "stable"' supported_go_versions.json | grep '"version"' | sed 's/.*"version": "\([^"]*\)".*/\1/')
latest_version=$(get_latest_versions)
# Check for new version of Go, and generate go collector test files
# Update supported_go_versions.json: shift stable to oldstable, add new version as stable
if [[ ! $current_version =~ $latest_version ]]; then
echo "New Go version available: $latest_version"
echo "Updating supported_go_versions.json and generating Go Collector test files"
# Get the current stable version (which will become oldstable)
current_stable_version=$(grep -A 1 '"label": "stable"' supported_go_versions.json | grep '"version"' | sed 's/.*"version": "\([^"]*\)".*/\1/')
# Create new JSON structure with new version as stable, current stable as oldstable
cat > supported_go_versions.json <<EOF
{
"versions": [
{
"label": "stable",
"version": "$latest_version",
"name": "Tests (stable)"
},
{
"label": "oldstable",
"version": "$current_stable_version",
"name": "Tests (oldstable)"
}
]
}
EOF
else
echo "No new Go version detected. Current Go version is: $current_version"
fi