-
Notifications
You must be signed in to change notification settings - Fork 559
script to add versioning info #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
404b7ad
version hook
lalitb 4ac3c68
add version hook files
lalitb 0ccca7d
format script
lalitb 34bd479
add header in script
lalitb 19fec61
update api version
lalitb eb44247
revert version.cc
lalitb 0def5eb
add updating ABI version
lalitb bcc2269
add versioning guidelines
lalitb 9387c1a
move tag to new version
lalitb f6b16a1
fix relative link, update comment in version.cc
lalitb 7c1ed7e
Update RELEASING.md
lalitb 6d4c8a2
another try on updating link
lalitb a54ddd7
added needed resources in docfx.json
lalitb 9dd8b72
Merge branch 'master' into version-hook-2
lalitb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # 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" && ! -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" | ||
| #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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ./pre-commit |
0
pre_release.sh → buildscripts/pre_release.sh
100644 → 100755
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,10 @@ | |
| "resource": [ | ||
| { | ||
| "files": [ | ||
|
|
||
| "api/**.h", | ||
| "api/**.cc", | ||
| "sdk/**.h", | ||
| "sdk/**.cc" | ||
| ] | ||
| } | ||
| ], | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace version | ||
| { | ||
| extern const int MAJOR_VERSION; | ||
| extern const int MINOR_VERSION; | ||
| extern const int PATCH_VERSION; | ||
| extern const char *PRE_RELEASE; | ||
| extern const char *BUILD_METADATA; | ||
| extern const int COUNT_NEW_COMMITS; | ||
| extern const char *BRANCH; | ||
| extern const char *COMMIT_HASH; | ||
| extern const char *FULL_VERSION; | ||
| extern const char *FULL_VERSION_WITH_BRANCH_COMMITHASH; | ||
| extern const char *BUILD_DATE; | ||
| } // namespace version | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| add_library(opentelemetry_version version.cc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Please DONOT touch this file. | ||
| // Any changes done here would be overwritten during release/build. | ||
|
|
||
| #include "opentelemetry/sdk/version/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace version | ||
| { | ||
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.