From dc573877463cecf21d44511a24554a5dc2e46137 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Fri, 25 Jun 2021 00:37:05 -0700 Subject: [PATCH] release.bash: make work on Linux Most releases of Linux use the GNU version of sed, while most releases of macOS use the BSD version of sed. For the -i flag, BSD always expects an argument, while GNU expects an optional argument in a different format. See https://www.freebsd.org/cgi/man.cgi?query=sed&sektion=&n=1 See https://www.gnu.org/software/sed/manual/html_node/Command_002dLine-Options.html#Command_002dLine-Options Change-Id: Id0f472553c8583d427524f59b36c376d6bc28786 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/330869 Trust: Joe Tsai Reviewed-by: Damien Neil --- release.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/release.bash b/release.bash index 13abc882b..427785d72 100755 --- a/release.bash +++ b/release.bash @@ -63,14 +63,18 @@ git change release git sync # Create commit for actual release. -sed -i "" -e "s/\(Minor *= *\)[0-9]*/\1$VERSION_MINOR/" internal/version/version.go -sed -i "" -e "s/\(Patch *= *\)[0-9]*/\1$VERSION_PATCH/" internal/version/version.go -sed -i "" -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go +INPLACE='-i ""' # BSD version of sed expects argument after -i +if [[ "$(sed --version)" == *"GNU"* ]]; then + INPLACE="-i" # GNU version of sed does not expect argument after -i +fi +sed $INPLACE -e "s/\(Minor *= *\)[0-9]*/\1$VERSION_MINOR/" internal/version/version.go +sed $INPLACE -e "s/\(Patch *= *\)[0-9]*/\1$VERSION_PATCH/" internal/version/version.go +sed $INPLACE -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go if ! [[ -z $GEN_VERSION ]]; then - sed -i "" -e "s/\(GenVersion *= *\)[0-9]*/\1$GEN_VERSION/" runtime/protoimpl/version.go + sed $INPLACE -e "s/\(GenVersion *= *\)[0-9]*/\1$GEN_VERSION/" runtime/protoimpl/version.go fi if ! [[ -z $MIN_VERSION ]]; then - sed -i "" -e "s/\(MinVersion *= *\)[0-9]*/\1$MIN_VERSION/" runtime/protoimpl/version.go + sed $INPLACE -e "s/\(MinVersion *= *\)[0-9]*/\1$MIN_VERSION/" runtime/protoimpl/version.go fi git commit -a -m "all: release $(version_string)" @@ -80,7 +84,7 @@ go test -mod=vendor -timeout=60m -count=1 integration_test.go "$@" -buildRelease # Create commit to start development after release. VERSION_PRERELEASE="${VERSION_PRERELEASE}.devel" # append ".devel" VERSION_PRERELEASE="${VERSION_PRERELEASE#"."}" # trim possible leading "." -sed -i "" -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go +sed $INPLACE -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go git commit -a -m "all: start $(version_string)" echo