-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate
executable file
·40 lines (33 loc) · 1.24 KB
/
update
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
#!/bin/bash
set -euo pipefail
check(){
nextversion="$1"
echo "Checking for next patch: $nextversion"
if wget -O /tmp/go.tgz "https://go.dev/dl/go$nextversion.linux-amd64.tar.gz"; then
sha="$(sha256sum /tmp/go.tgz)"
rm /tmp/go.tgz
sha="${sha%% *}"
echo "sha: [$sha]"
git mv "Dockerfile.$version" "Dockerfile.$nextversion"
sed -i "s/GOLANG_VERSION=.[0-9.]*/GOLANG_VERSION=$nextversion/;s/DIGEST='.*'/DIGEST='$sha'/" Dockerfile.$nextversion
git add "Dockerfile.$nextversion"
fi
}
version="$(ls Dockerfile.* | grep -v 1.10.8)"
version="${version#Dockerfile.}"
major="${version%%.*}"
minor="${version#*.}"
minor="${minor%.*}"
patch="${version##*.}"
if [ "$patch" = "${version#*.}" ]; then
patch="0"
fi
echo "Current major: $major minor: $minor patch: $patch"
check "$major.$minor.$(( $patch+1 ))"
check "$major.$(( $minor+1 ))"
check "$major.$(( $minor+1 )).0"
check "$(( $major+1 ))"
[ -t 1 ] && echo "Checking for updated golangci-lint at https://github.com/repos/golangci/golangci-lint"
golangci="$(curl https://api.github.com/repos/golangci/golangci-lint/releases -s | jq -r '.[].tag_name' | sort -rV | head -n 1)"
[ -t 1 ] && echo "Latest version of golangci-lint is $golangci"
sed -E -i'' "/golangci-lint/s/v[0-9.]+ /$golangci /" Dockerfile*