summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentelemetry-cpp/buildscripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/jaegertracing/opentelemetry-cpp/buildscripts
parentInitial commit. (diff)
downloadceph-b26c4052f3542036551aa9dec9caa4226e456195.tar.xz
ceph-b26c4052f3542036551aa9dec9caa4226e456195.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/buildscripts')
-rwxr-xr-xsrc/jaegertracing/opentelemetry-cpp/buildscripts/pre-commit80
l---------src/jaegertracing/opentelemetry-cpp/buildscripts/pre-merge-commit1
-rwxr-xr-xsrc/jaegertracing/opentelemetry-cpp/buildscripts/pre_release.sh74
3 files changed, 155 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-commit b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-commit
new file mode 100755
index 000000000..aa7e8cc6f
--- /dev/null
+++ b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-commit
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+set -eo pipefail
+
+if [[ ! -w "$(pwd)/sdk/src/version/version.cc" && ! -w "$(pwd)/api/include/opentelemetry/version.h" ]]; then
+ echo "Error: Version file(s) are not writable. Check permissions and try again."
+ exit 1
+fi
+
+# format: "v<MAJOR>.<MINOR>.<PATCH>-<PRERELEASE>+<BUILDMETADATA>-<NUMBER_OF_NEW_COMMITS>-g<LAST_COMMIT_HASH>""
+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-]+)*)?-([0-9]+)-g([0-9|a-z]+)$"
+git_tag=$(git describe --tags --long 2>/dev/null) || true
+if [[ ! -z $git_tag ]] && [[ $git_tag =~ $semver_regex ]]; then
+ major="${BASH_REMATCH[1]}"
+ minor="${BASH_REMATCH[2]}"
+ patch="${BASH_REMATCH[3]}"
+ pre_release="${BASH_REMATCH[5]}" #optional
+ build_metadata="${BASH_REMATCH[7]}" #optional
+ count_new_commits="${BASH_REMATCH[9]}"
+ latest_commit_hash="${BASH_REMATCH[10]}"
+ if [[ -z ${major} ]] || [[ -z ${minor} ]] || [[ -z ${patch} ]] || [[ -z ${count_new_commits} ]] || [[ -z ${latest_commit_hash} ]]; then
+ echo "Error: Incorrect tag format recevived. Exiting.."
+ exit 1
+ fi
+else
+ major=0 && minor=0 && patch=0 && pre_release="" && build_metadata="" && count_new_commits=0
+ latest_commit_hash="$(git rev-parse --short HEAD)"
+fi
+: ${pre_release:="NONE"} # use default string if not defined
+: ${build_metadata:="NONE"} # use default string if not defined
+latest_commit_hash=$(git rev-parse ${latest_commit_hash}) # get full hash from short
+
+if [[ -z ${latest_commit_hash} ]]; then
+ echo "Error: Incorrect short hash received. Exiting.."
+ exit 1
+fi
+
+branch="$(git rev-parse --abbrev-ref HEAD)"
+short_version="${major}.${minor}.${patch}"
+full_version="${short_version}-${pre_release}-${build_metadata}-${count_new_commits}-${branch}-${latest_commit_hash}"
+
+# Update api version.h
+sed -i "/^\#define OPENTELEMETRY_VERSION/c\#define OPENTELEMETRY_VERSION \"${short_version}\"" "$(pwd)/api/include/opentelemetry/version.h"
+git add "$(pwd)/api/include/opentelemetry/version.h"
+
+# Update sdk version.cc
+cat > "$(pwd)/sdk/src/version/version.cc" <<END
+// Please DONOT touch this file.
+// Any changes done here would be overwritten by pre-commit git hook
+
+#include "opentelemetry/sdk/version/version.h"
+
+OPENTELEMETRY_BEGIN_NAMESPACE
+namespace sdk
+{
+namespace version
+{
+ const int MAJOR_VERSION = ${major};
+ const int MINOR_VERSION = ${minor};
+ const int PATCH_VERSION = ${patch};
+ const char* PRE_RELEASE = "${pre_release}";
+ const char* BUILD_METADATA = "${build_metadata}";
+ const int COUNT_NEW_COMMITS = ${count_new_commits};
+ const char* BRANCH = "${branch}";
+ const char* COMMIT_HASH = "${latest_commit_hash}";
+ const char* SHORT_VERSION = "${short_version}";
+ const char* FULL_VERSION = "${full_version}";
+ const char* BUILD_DATE = "$(date -u)";
+}
+}
+OPENTELEMETRY_END_NAMESPACE
+END
+git add "$(pwd)/sdk/src/version/version.cc"
+
+# Update documentation version
+sed -i "/^release =/crelease = \"${short_version}\"" "$(pwd)/docs/public/conf.py"
+git add "$(pwd)/docs/public/conf.py"
diff --git a/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-merge-commit b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-merge-commit
new file mode 120000
index 000000000..f1342a283
--- /dev/null
+++ b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre-merge-commit
@@ -0,0 +1 @@
+./pre-commit \ No newline at end of file
diff --git a/src/jaegertracing/opentelemetry-cpp/buildscripts/pre_release.sh b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre_release.sh
new file mode 100755
index 000000000..2382d3d68
--- /dev/null
+++ b/src/jaegertracing/opentelemetry-cpp/buildscripts/pre_release.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+usage() { echo "Usage: $0 -t <tag>" 1>&2; exit 1; }
+
+while getopts ":t:" o; do
+ case "${o}" in
+ t)
+ tag=${OPTARG}
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+if [ ! -z "${t}" ]; then
+ usage
+fi
+
+#validate tag
+semver_regex="^(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
+ echo "${tag} is valid semver tag"
+else
+ echo "Error: ${tag} is not a valid semver tag. Exiting"
+ exit -1
+fi
+
+#ensure tag doesn't exits
+if [[ $(git tag --list ${tag}) ]]; then
+ echo "Error: Tag ${tag} already exists. Exiting"
+ exit -1
+fi
+
+if ! git diff --quiet; then \
+ echo "Error: Working tree is not clean, can't proceed with the release process\n"
+ git status
+ git diff
+ exit 1
+fi
+
+# check changelog exists
+changelog_file="./CHANGELOG.md"
+if [ ! -f $changelog_file ]; then
+ echo "Error: $changelog_file doesn't exist. Ensure that you are running this script from repo root directory "
+ exit 1
+fi
+
+if [ ! grep -q "^\#\# \[Unreleased\]$" $changelog_file ]; then
+ echo "Error: $changelog_file doesn't contain Unreleased information. Please update the file with changes and run this script again."
+ exit 1
+fi
+
+git checkout -b pre_release_${tag} main
+if [ $? -ne 0 ]; then
+ echo "Error: Cannot create release branch. Ensure you have sufficient permissions to repo and try again."
+ exit 1
+fi
+
+# update CHANGELOG.md
+date=$(date '+%Y-%m-%d')
+sed -i "/\#\# \[Unreleased\]/a\\ \n\#\# \[${tag}\] ${date}" $changelog_file
+if [ $? -ne 0 ]; then
+ echo "Error: Cannot update CHANGELOG.md file. Update it manually, create the ${tag} and push changes to upstream"
+ exit 1
+fi
+
+git add CHANGELOG.md
+git commit -m "Prepare for releasing ${tag}"
+
+echo "Now validate the changes using git diff main, create the ${tag} and push changes to upstream"
+echo