Skip to content

Commit

Permalink
Pre-release script fixes (#592)
Browse files Browse the repository at this point in the history
* Make pre_release.sh script work with GNU

The `-i` sed flag is for doing in-place updates of the file. On some
systems it requires a parameter, on other (GNU) the parameter is
optional, but should be "glued" to the flag (`-i.bak` for example).
That's is problematic, so just emulate the in-place updates with
copies and removals.

* Update the version string in sdk with the pre-release script

This was a missing step, which is why we still have a version string
"0.2.3" while in reality it should be "0.3.0". Hopefully it will be
something to fix in "0.3.1" or what the next release version will be.

* Ensure clean git state when doing a release

The script does `git add .` which adds everything in the tree, even
the untracked files. Make sure that there are none of those.
  • Loading branch information
krnowak authored Mar 24, 2020
1 parent d648712 commit dff6265
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pre_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dff6265

Please sign in to comment.