diff --git a/pre_release.sh b/pre_release.sh index 2f069f735a9..391e9e04568 100755 --- a/pre_release.sh +++ b/pre_release.sh @@ -54,16 +54,33 @@ if [ ${TAG_FOUND} = ${TAG} ] ; then exit -1 fi +# Get version for sdk/opentelemetry.go +OTEL_VERSION=$(echo "${TAG}" | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+') +# Strip leading v +OTEL_VERSION="${OTEL_VERSION#v}" cd $(dirname $0) +if ! git diff --quiet; then \ + printf "Working tree is not clean, can't proceed with the release process\n" + git status + git diff + exit 1 +fi + +# Update sdk/opentelemetry.go +cp ./sdk/opentelemetry.go ./sdk/opentelemetry.go.bak +sed 's/\(return "\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1'"${OTEL_VERSION}"'/' ./sdk/opentelemetry.go.bak >./sdk/opentelemetry.go +rm -f ./sdk/opentelemetry.go.bak + # Update go.mod git checkout -b pre_release_${TAG} master PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | egrep -v 'tools' | sed 's/^\.\///' | sort) for dir in $PACKAGE_DIRS; do - sed -i .bak "s/opentelemetry.io\/otel\([^ ]*\) v[0-9]*\.[0-9]*\.[0-9]/opentelemetry.io\/otel\1 ${TAG}/" ${dir}/go.mod - rm -f ${dir}/go.mod.bak + cp "${dir}/go.mod" "${dir}/go.mod.bak" + sed "s/opentelemetry.io\/otel\([^ ]*\) v[0-9]*\.[0-9]*\.[0-9]/opentelemetry.io\/otel\1 ${TAG}/" "${dir}/go.mod.bak" >"${dir}/go.mod" + rm -f "${dir}/go.mod.bak" done # Run lint to update go.sum