From 404b7ad1ae7fa06734e64258aa33fd7e5513b2d0 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Fri, 20 Nov 2020 20:46:56 +0530 Subject: [PATCH 01/13] version hook --- RELEASING.md | 18 ++++- buildscripts/pre-commit | 69 +++++++++++++++++++ buildscripts/pre-merge-commit | 1 + buildscripts/pre_merge_commit_wrapper.sh | 0 pre_release.sh => buildscripts/pre_release.sh | 0 .../opentelemetry/sdk/version/version.h | 24 +++++++ sdk/src/version/CMakeLists.txt | 1 + sdk/src/version/version.cc | 23 +++++++ 8 files changed, 134 insertions(+), 2 deletions(-) create mode 100755 buildscripts/pre-commit create mode 120000 buildscripts/pre-merge-commit create mode 100644 buildscripts/pre_merge_commit_wrapper.sh rename pre_release.sh => buildscripts/pre_release.sh (100%) mode change 100644 => 100755 create mode 100644 sdk/include/opentelemetry/sdk/version/version.h create mode 100644 sdk/src/version/CMakeLists.txt create mode 100644 sdk/src/version/version.cc diff --git a/RELEASING.md b/RELEASING.md index c4a111fdbf..2affffaac4 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -5,8 +5,8 @@ 1. Make sure all relevant changes for this release are included under `Unreleased` section in `CHANGELOG.md` and are in language that non-contributors to the project can understand. 2. Run the pre-release script. It creates a branch `pre_release_` and updates `CHANGELOG.md` with the ``: - ``` - ./pre_release.sh -t + ```console + ./buildscripts/pre_release.sh -t ``` 3. Verify that CHANGELOG.md is updated properly: ``` @@ -35,5 +35,19 @@ Failure to do so will leave things in a broken state. git push upstream ``` +## Versioning: + +Once tag is created, it's time to use that tag for Runtime Versioning + +1. Create a new brach for updating version information in `sdk/src/version.cc` + ``` + git checkout -b update_version_${tag} master + ``` +2. Run the pre-commit script to update the version: + ```console + ./buildscripts/pre-commit + ``` +3. Push the changes to upstream and create a Pull Request on GitHub. + ## Release Finally create a Release for the new on GitHub. The release body should include all the release notes from the Changelog for this release. diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit new file mode 100755 index 0000000000..d80cb400c8 --- /dev/null +++ b/buildscripts/pre-commit @@ -0,0 +1,69 @@ +#!/usr/bin/env sh + +# This script is supposed to execute as pre-commit / per-merge-commit hook to recreate version.cc with latest build information from git +set -eo pipefail + +if [[ ! -w "$(pwd)/sdk/src/version/version.cc" ]]; then + echo "Error: File is not writable. Check permissions again." + exit 1 +fi + +# format: "v..-+--g"" +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[6]}" #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 + 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)" +if [[ -z ${major} ]] && [[ -z ${minor} ]] && [[ -z $patch ]]; then + short_version="" + full_version="${branch}-${latest_commit_hash}" +else + short_version="${major}.${minor}.${patch}" + full_version="${short_version}-${pre-release}-${build_metadata}-${count_new_commits}-${branch}-${latest_commit_hash}" +fi +cat > $(pwd)/sdk/src/version/version.cc < Date: Fri, 20 Nov 2020 21:48:23 +0530 Subject: [PATCH 02/13] add version hook files --- RELEASING.md | 2 +- buildscripts/pre-commit | 19 +++++++------- .../opentelemetry/sdk/version/version.h | 25 +++++++++---------- sdk/src/CMakeLists.txt | 1 + sdk/src/version/CMakeLists.txt | 2 +- sdk/src/version/version.cc | 25 ++++++++++--------- 6 files changed, 38 insertions(+), 36 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 2affffaac4..b5db87a3b3 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -45,7 +45,7 @@ Once tag is created, it's time to use that tag for Runtime Versioning ``` 2. Run the pre-commit script to update the version: ```console - ./buildscripts/pre-commit + ./buildscripts/pre-commit ``` 3. Push the changes to upstream and create a Pull Request on GitHub. diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit index d80cb400c8..17da055175 100755 --- a/buildscripts/pre-commit +++ b/buildscripts/pre-commit @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # This script is supposed to execute as pre-commit / per-merge-commit hook to recreate version.cc with latest build information from git set -eo pipefail @@ -16,7 +16,7 @@ if [[ ! -z $git_tag ]] && [[ $git_tag =~ $semver_regex ]]; then minor="${BASH_REMATCH[2]}" patch="${BASH_REMATCH[3]}" pre_release="${BASH_REMATCH[5]}" #optional - build_metadata="${BASH_REMATCH[6]}" #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 @@ -24,8 +24,11 @@ if [[ ! -z $git_tag ]] && [[ $git_tag =~ $semver_regex ]]; then 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 +echo "PRE_REL:$pre_release" +echo "COUNT:$count_new_commits" : ${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 @@ -35,13 +38,8 @@ if [[ -z ${latest_commit_hash} ]]; then exit 1 fi branch="$(git rev-parse --abbrev-ref HEAD)" -if [[ -z ${major} ]] && [[ -z ${minor} ]] && [[ -z $patch ]]; then - short_version="" - full_version="${branch}-${latest_commit_hash}" -else short_version="${major}.${minor}.${patch}" - full_version="${short_version}-${pre-release}-${build_metadata}-${count_new_commits}-${branch}-${latest_commit_hash}" -fi + full_version="${short_version}-${pre_release}-${build_metadata}-${count_new_commits}-${branch}-${latest_commit_hash}" cat > $(pwd)/sdk/src/version/version.cc < Date: Fri, 20 Nov 2020 21:53:35 +0530 Subject: [PATCH 03/13] format script --- buildscripts/pre-commit | 8 +++----- buildscripts/pre_merge_commit_wrapper.sh | 0 2 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 buildscripts/pre_merge_commit_wrapper.sh diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit index 17da055175..4bd993938f 100755 --- a/buildscripts/pre-commit +++ b/buildscripts/pre-commit @@ -27,8 +27,6 @@ else major=0 && minor=0 && patch=0 && pre_release="" && build_metadata="" && count_new_commits=0 latest_commit_hash="$(git rev-parse --short HEAD)" fi -echo "PRE_REL:$pre_release" -echo "COUNT:$count_new_commits" : ${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 @@ -38,9 +36,9 @@ if [[ -z ${latest_commit_hash} ]]; then 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}" -cat > $(pwd)/sdk/src/version/version.cc < "$(pwd)/sdk/src/version/version.cc" < Date: Fri, 20 Nov 2020 22:07:42 +0530 Subject: [PATCH 04/13] add header in script --- buildscripts/pre-commit | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit index 4bd993938f..2d8c10becb 100755 --- a/buildscripts/pre-commit +++ b/buildscripts/pre-commit @@ -1,6 +1,10 @@ #!/usr/bin/env bash -# This script is supposed to execute as pre-commit / per-merge-commit hook to recreate version.cc with latest build information from git +# This script is supposed to execute tp recreate version.cc. It can be executed as: +# git pre-commit hook +# git per-merge-commit hook +# manually as part of release process ( refer RELEASING.md ) + set -eo pipefail if [[ ! -w "$(pwd)/sdk/src/version/version.cc" ]]; then @@ -64,5 +68,4 @@ namespace version } OPENTELEMETRY_END_NAMESPACE END - git add "$(pwd)/sdk/src/version/version.cc" From 19fec613b2703a9652a147482aeaabccb0c98568 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 24 Nov 2020 11:39:02 +0530 Subject: [PATCH 05/13] update api version --- buildscripts/pre-commit | 11 ++++++++--- sdk/src/version/version.cc | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit index 2d8c10becb..de4e42d696 100755 --- a/buildscripts/pre-commit +++ b/buildscripts/pre-commit @@ -1,14 +1,14 @@ #!/usr/bin/env bash -# This script is supposed to execute tp recreate version.cc. It can be executed as: +# This script is supposed to be executed to recreate version.cc. It can be executed as: # git pre-commit hook # git per-merge-commit hook # manually as part of release process ( refer RELEASING.md ) set -eo pipefail -if [[ ! -w "$(pwd)/sdk/src/version/version.cc" ]]; then - echo "Error: File is not writable. Check permissions again." +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 @@ -39,9 +39,14 @@ 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" +#update sdk version.cc cat > "$(pwd)/sdk/src/version/version.cc" < Date: Tue, 24 Nov 2020 11:50:26 +0530 Subject: [PATCH 06/13] revert version.cc --- sdk/src/version/version.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 8730a7dc00..07e9905d46 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -8,17 +8,17 @@ namespace sdk { namespace version { - const int MAJOR_VERSION = 2; - const int MINOR_VERSION = 1; - const int PATCH_VERSION = 1; - const char* PRE_RELEASE = "test"; - const char* BUILD_METADATA = "NONE"; - const int COUNT_NEW_COMMITS = 6; - const char* BRANCH = "version-hook-2"; - const char* COMMIT_HASH = "34bd479a77447780a2185bee6f7b8ffc377bb58c"; - const char* SHORT_VERSION = "2.1.1"; - const char* FULL_VERSION = "2.1.1-test-NONE-6-version-hook-2-34bd479a77447780a2185bee6f7b8ffc377bb58c"; - const char* BUILD_DATE = "Tue Nov 24 06:04:37 UTC 2020"; -} -} +const int MAJOR_VERSION = 0; +const int MINOR_VERSION = 0; +const int PATCH_VERSION = 0; +const char *PRE_RELEASE = ""; +const char *BUILD_METADATA = ""; +const int COUNT_NEW_COMMITS = 0; +const char *BRANCH = ""; +const char *COMMIT_HASH = ""; +const char *SHORT_VERSION = ""; +const char *FULL_VERSION = ""; +const char *BUILD_DATE = ""; +} // namespace version +} // namespace sdk OPENTELEMETRY_END_NAMESPACE From 0def5eb3a10226b37387ad3267fd7e3e2713d279 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 30 Nov 2020 22:12:41 +0530 Subject: [PATCH 07/13] add updating ABI version --- RELEASING.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index b5db87a3b3..3af4e11342 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -39,7 +39,7 @@ Failure to do so will leave things in a broken state. Once tag is created, it's time to use that tag for Runtime Versioning -1. Create a new brach for updating version information in `sdk/src/version.cc` +1. Create a new brach for updating version information in [version.cc](sdk/src/version.cc). ``` git checkout -b update_version_${tag} master ``` @@ -47,7 +47,10 @@ Once tag is created, it's time to use that tag for Runtime Versioning ```console ./buildscripts/pre-commit ``` -3. Push the changes to upstream and create a Pull Request on GitHub. + +3. Check if any changes masde since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](api/include/opentelemetry/version.h). + +4. Push the changes to upstream and create a Pull Request on GitHub. ## Release Finally create a Release for the new on GitHub. The release body should include all the release notes from the Changelog for this release. From bcc226970f04591ac851d82ab3a81d9e564bfce3 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 30 Nov 2020 22:33:11 +0530 Subject: [PATCH 08/13] add versioning guidelines --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 726419a4c6..cb6f818b41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Guideline to update the version: +Increment the: +- MAJOR version when you make incompatible API/ABI changes, +- MINOR version when you add functionality in a backwards compatible manner, and +- PATCH version when you make backwards compatible bug fixes. + + ## [Unreleased] ### Added * Trace API and SDK From 9387c1a0631a39b1ee3e5bef5f7c13e9a1ce7e17 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 30 Nov 2020 22:55:27 +0530 Subject: [PATCH 09/13] move tag to new version --- RELEASING.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 3af4e11342..5a04081827 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -39,7 +39,7 @@ Failure to do so will leave things in a broken state. Once tag is created, it's time to use that tag for Runtime Versioning -1. Create a new brach for updating version information in [version.cc](sdk/src/version.cc). +1. Create a new brach for updating version information in [version.cc](./sdk/src/version.cc). ``` git checkout -b update_version_${tag} master ``` @@ -48,9 +48,17 @@ Once tag is created, it's time to use that tag for Runtime Versioning ./buildscripts/pre-commit ``` -3. Check if any changes masde since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](api/include/opentelemetry/version.h). +3. Check if any changes masde since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](./api/include/opentelemetry/version.h). 4. Push the changes to upstream and create a Pull Request on GitHub. +5. Once changes are merged, move the tag created earlier to the new commit hash from step 4. + + ``` + git tag -f + git push --tags --force + + ``` + ## Release Finally create a Release for the new on GitHub. The release body should include all the release notes from the Changelog for this release. From f6b16a115c971abf009f4405c72ef9bd6f275592 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 30 Nov 2020 23:33:19 +0530 Subject: [PATCH 10/13] fix relative link, update comment in version.cc --- RELEASING.md | 2 +- sdk/src/version/version.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 5a04081827..f9bc289c0f 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -39,7 +39,7 @@ Failure to do so will leave things in a broken state. Once tag is created, it's time to use that tag for Runtime Versioning -1. Create a new brach for updating version information in [version.cc](./sdk/src/version.cc). +1. Create a new brach for updating version information in `./sdk/src/version.cc`. ``` git checkout -b update_version_${tag} master ``` diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 07e9905d46..3a50a9cd1b 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -1,5 +1,5 @@ // Please DONOT touch this file. -// Any changes done here would be overwritten by pre-commit git hook +// Any changes done here would be overwritten during release/build. #include "opentelemetry/sdk/version/version.h" From 7c1ed7e9e3845a34600666ae2819bd66d958a77e Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 30 Nov 2020 23:40:55 +0530 Subject: [PATCH 11/13] Update RELEASING.md Co-authored-by: Tom Tan --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index f9bc289c0f..3ee2088846 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -48,7 +48,7 @@ Once tag is created, it's time to use that tag for Runtime Versioning ./buildscripts/pre-commit ``` -3. Check if any changes masde since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](./api/include/opentelemetry/version.h). +3. Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](./api/include/opentelemetry/version.h). 4. Push the changes to upstream and create a Pull Request on GitHub. From 6d4c8a21518384ec6083a0849ea3543d11d88354 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 1 Dec 2020 00:24:27 +0530 Subject: [PATCH 12/13] another try on updating link --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 3ee2088846..1029ef07c1 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -48,7 +48,7 @@ Once tag is created, it's time to use that tag for Runtime Versioning ./buildscripts/pre-commit ``` -3. Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](./api/include/opentelemetry/version.h). +3. Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](/api/include/opentelemetry/version.h). 4. Push the changes to upstream and create a Pull Request on GitHub. From a54ddd7a8f62ed009c4b0eb4abfc993d51183db1 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 1 Dec 2020 00:58:51 +0530 Subject: [PATCH 13/13] added needed resources in docfx.json --- RELEASING.md | 2 +- ci/docfx.json | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 1029ef07c1..1155ce8900 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -48,7 +48,7 @@ Once tag is created, it's time to use that tag for Runtime Versioning ./buildscripts/pre-commit ``` -3. Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](/api/include/opentelemetry/version.h). +3. Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](api/include/opentelemetry/version.h). 4. Push the changes to upstream and create a Pull Request on GitHub. diff --git a/ci/docfx.json b/ci/docfx.json index 9de16e8f9b..bc026d6232 100644 --- a/ci/docfx.json +++ b/ci/docfx.json @@ -11,7 +11,10 @@ "resource": [ { "files": [ - + "api/**.h", + "api/**.cc", + "sdk/**.h", + "sdk/**.cc" ] } ],