mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-25 12:04:40 +02:00
Scripts for releasing. (#576)
* Scripts for releasing. - fixes #510 * fix review comments. Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This commit is contained in:
parent
7623fc544a
commit
a15e507b2e
36
RELEASING.md
Normal file
36
RELEASING.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Release Process
|
||||||
|
|
||||||
|
## Pre-Release
|
||||||
|
Update go.mod for submodules to depend on the new release which will happen
|
||||||
|
in the next step. This will create build failure for those who depend
|
||||||
|
on the master branch instead or released version. But they shouldn't be
|
||||||
|
depending on the master. So it is not a concern.
|
||||||
|
|
||||||
|
1. Run the pre-release script. It creates a branch pre_release_<tag> to make the changes.
|
||||||
|
2. Verify the changes.
|
||||||
|
3. Push the changes to upstream.
|
||||||
|
4. Create a PR on github and merge the PR once approved.
|
||||||
|
|
||||||
|
```
|
||||||
|
./pre-release.sh -t <new tag>
|
||||||
|
git diff master
|
||||||
|
git push
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Tag
|
||||||
|
Now create a new Tag on the commit hash of the changes made in pre-release step.
|
||||||
|
Use the same tag as used in the pre-release step.
|
||||||
|
|
||||||
|
1. Run the tag.sh script.
|
||||||
|
2. Push tags upstream. Make sure you run this for all sub-modules as well.
|
||||||
|
|
||||||
|
```
|
||||||
|
./tag.sh -t <new tag> -c <commit-hash>
|
||||||
|
git push upstream <new tag>
|
||||||
|
git push upstream <submodules-path/new tag>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Release
|
||||||
|
Now create a release for the new tag on github. tag.sh script generates commit logs since
|
||||||
|
last release. Use that to draft the new release.
|
64
pre_release.sh
Executable file
64
pre_release.sh
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
help()
|
||||||
|
{
|
||||||
|
printf "\n"
|
||||||
|
printf "Usage: $0 -t tag\n"
|
||||||
|
printf "\t-t Unreleased tag. Update all go.mod with this tag.\n"
|
||||||
|
exit 1 # Exit script after printing help
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "t:" opt
|
||||||
|
do
|
||||||
|
case "$opt" in
|
||||||
|
t ) TAG="$OPTARG" ;;
|
||||||
|
? ) help ;; # Print help
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print help in case parameters are empty
|
||||||
|
if [ -z "$TAG" ]
|
||||||
|
then
|
||||||
|
printf "Tag is missing\n";
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate semver
|
||||||
|
SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
|
||||||
|
if [[ "${TAG}" =~ ${SEMVER_REGEX} ]]; then
|
||||||
|
printf "${TAG} is valid semver tag.\n"
|
||||||
|
else
|
||||||
|
printf "${TAG} is not a valid semver tag.\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAG_FOUND=`git tag --list ${TAG}`
|
||||||
|
if [ ${TAG_FOUND} = ${TAG} ] ; then
|
||||||
|
printf "Tag ${TAG} already exists\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run lint to update go.sum
|
||||||
|
make lint
|
||||||
|
|
||||||
|
# Add changes and commit.
|
||||||
|
git add .
|
||||||
|
make ci
|
||||||
|
git commit -m "Prepare for releasing $TAG"
|
||||||
|
|
||||||
|
printf "Now run following to verify the changes.\ngit diff master\n"
|
||||||
|
printf "\nThen push the changes to upstream\n"
|
75
tag.sh
Executable file
75
tag.sh
Executable file
@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
help()
|
||||||
|
{
|
||||||
|
printf "\n"
|
||||||
|
printf "Usage: $0 -t tag -c commit-hash\n"
|
||||||
|
printf "\t-t New tag that you would like to create\n"
|
||||||
|
printf "\t-c Commit hash to associate with the new tag\n"
|
||||||
|
exit 1 # Exit script after printing help
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "t:c:" opt
|
||||||
|
do
|
||||||
|
case "$opt" in
|
||||||
|
t ) TAG="$OPTARG" ;;
|
||||||
|
c ) COMMIT_HASH="$OPTARG" ;;
|
||||||
|
? ) help ;; # Print help
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print help in case parameters are empty
|
||||||
|
if [ -z "$TAG" ] || [ -z "${COMMIT_HASH}" ]
|
||||||
|
then
|
||||||
|
printf "Some or all of the parameters are missing\n";
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate semver
|
||||||
|
SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "${TAG}" =~ ${SEMVER_REGEX} ]]; then
|
||||||
|
printf "${TAG} is valid semver tag.\n"
|
||||||
|
else
|
||||||
|
printf "${TAG} is not a valid semver tag.\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
# Check if the commit-hash is valid
|
||||||
|
COMMIT_FOUND=`git log -50 --pretty=format:"%H" | grep ${COMMIT_HASH}`
|
||||||
|
if [ "${COMMIT_FOUND}" != "${COMMIT_HASH}" ] ; then
|
||||||
|
printf "Commit ${COMMIT_HASH} not found\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the tag doesn't alread exists.
|
||||||
|
TAG_FOUND=`git tag --list ${TAG}`
|
||||||
|
if [ "${TAG_FOUND}" = "${TAG}" ] ; then
|
||||||
|
printf "Tag ${TAG} already exists\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save most recent tag for generating logs
|
||||||
|
TAG_CURRENT=`git tag | grep '^v' | tail -1`
|
||||||
|
|
||||||
|
PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | egrep -v 'tools' | sed 's/^\.\///' | sort)
|
||||||
|
|
||||||
|
# Create tag for root module
|
||||||
|
git tag -a "${TAG}" -m "Version ${TAG}" ${COMMIT_HASH}
|
||||||
|
|
||||||
|
# Create tag for submodules
|
||||||
|
for dir in $PACKAGE_DIRS; do
|
||||||
|
git tag -a "${dir}/${TAG}" -m "Version ${dir}/${TAG}" ${COMMIT_HASH}
|
||||||
|
done
|
||||||
|
|
||||||
|
# Generate commit logs
|
||||||
|
printf "New tag ${TAG} created.\n"
|
||||||
|
printf "\n\n\nChange log since previous tag ${TAG_CURRENT}\n"
|
||||||
|
printf "======================================\n"
|
||||||
|
git --no-pager log --pretty=oneline ${TAG_CURRENT}..${TAG}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user