2022-04-21 17:10:14 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-04-10 15:36:59 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-04-21 17:10:14 +00:00
|
|
|
|
|
|
|
set -euo pipefail
|
2020-01-16 15:00:15 +00:00
|
|
|
|
2020-05-14 21:27:42 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "usage: $0 GO_VERSION"
|
2022-04-21 17:10:14 +00:00
|
|
|
echo "(run in project directory)"
|
2020-12-06 23:02:32 +00:00
|
|
|
echo "For example: $0 1.15.5"
|
2020-05-14 21:27:42 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-16 15:00:15 +00:00
|
|
|
golang_version="$1"
|
|
|
|
|
2022-04-21 17:10:14 +00:00
|
|
|
# read current version from canonical .go-version file
|
|
|
|
current_version=$(cat .go-version)
|
2020-12-18 18:34:12 +00:00
|
|
|
if [ -z "${current_version}" ]; then
|
|
|
|
echo "unable to find current go version"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-02 18:55:02 +00:00
|
|
|
echo "--> Replacing Go ${current_version} with Go ${golang_version} ..."
|
2020-01-16 15:00:15 +00:00
|
|
|
|
2022-04-21 17:10:14 +00:00
|
|
|
# force the canonical .go-version file
|
|
|
|
echo "${golang_version}" > .go-version
|
|
|
|
|
2020-01-16 15:00:15 +00:00
|
|
|
# To support both GNU and BSD sed, the regex is looser than it needs to be.
|
|
|
|
# Specifically, we use "* instead of "?, which relies on GNU extension without much loss of
|
2020-01-27 14:10:38 +00:00
|
|
|
# correctness in practice.
|
2022-04-21 17:10:14 +00:00
|
|
|
|
2022-03-18 17:47:38 +00:00
|
|
|
sed -i'' -e "s|GO_VERSION:[ \"]*[.0-9]*\"*|GO_VERSION: ${golang_version}|g" \
|
|
|
|
.github/workflows/test-core.yaml
|
|
|
|
|
2021-03-09 18:34:34 +00:00
|
|
|
sed -i'' -e "s|\\(Install .Go\\) [.0-9]*|\\1 ${golang_version}|g" \
|
|
|
|
contributing/README.md
|
2020-01-16 15:00:15 +00:00
|
|
|
|
|
|
|
sed -i'' -e "s|go_version=\"*[^\"]*\"*$|go_version=\"${golang_version}\"|g" \
|
2023-03-28 13:18:48 +00:00
|
|
|
scripts/linux-priv-go.sh scripts/release/mac-remote-build
|
2020-01-16 15:00:15 +00:00
|
|
|
|
2020-03-02 18:55:02 +00:00
|
|
|
echo "--> Checking if there is any remaining references to old versions..."
|
2021-10-01 13:41:25 +00:00
|
|
|
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
|
2020-01-16 15:00:15 +00:00
|
|
|
then
|
2021-03-09 18:34:34 +00:00
|
|
|
echo " ^^ files may contain references to old golang version" >&2
|
2020-01-16 15:00:15 +00:00
|
|
|
echo " update script and run again" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|