github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/scripts/update_golang_version.sh (about) 1 #!/usr/bin/env bash 2 3 set -euo pipefail 4 5 if [ -z "$1" ]; then 6 echo "usage: $0 GO_VERSION" 7 echo "(run in project directory)" 8 echo "For example: $0 1.15.5" 9 exit 1 10 fi 11 12 golang_version="$1" 13 14 # read current version from canonical .go-version file 15 current_version=$(cat .go-version) 16 if [ -z "${current_version}" ]; then 17 echo "unable to find current go version" 18 exit 1 19 fi 20 echo "--> Replacing Go ${current_version} with Go ${golang_version} ..." 21 22 # force the canonical .go-version file 23 echo "${golang_version}" > .go-version 24 25 # To support both GNU and BSD sed, the regex is looser than it needs to be. 26 # Specifically, we use "* instead of "?, which relies on GNU extension without much loss of 27 # correctness in practice. 28 29 sed -i'' -e "s|/golang:[.0-9]*|/golang:${golang_version}|g" .circleci/config.yml 30 sed -i'' -e "s|GOLANG_VERSION:[ \"]*[.0-9]*\"*|GOLANG_VERSION: ${golang_version}|g" \ 31 .circleci/config.yml 32 33 sed -i'' -e "s|GO_VERSION:[ \"]*[.0-9]*\"*|GO_VERSION: ${golang_version}|g" \ 34 .github/workflows/test-core.yaml 35 36 sed -i'' -e "s|\\(Install .Go\\) [.0-9]*|\\1 ${golang_version}|g" \ 37 contributing/README.md 38 39 sed -i'' -e "s|go_version=\"*[^\"]*\"*$|go_version=\"${golang_version}\"|g" \ 40 scripts/vagrant-linux-priv-go.sh scripts/release/mac-remote-build 41 42 echo "--> Checking if there is any remaining references to old versions..." 43 if git grep -I --fixed-strings "${current_version}" | grep -v -e CHANGELOG.md -e .changelog/ -e vendor/ -e website/ -e ui/ -e contributing/golang.md -e '.*.go:' -e go.sum -e go.mod -e LICENSE 44 then 45 echo " ^^ files may contain references to old golang version" >&2 46 echo " update script and run again" >&2 47 exit 1 48 fi