Skip to content

Commit

Permalink
Introduce a top-level Version() and SemVersion() function (#225)
Browse files Browse the repository at this point in the history
* Introduce a top-level `Version()` and `SemVersion()` function.

These are intended to be used by submodules within the repo that need
to specify an "instrumentation version" when creating a tracer or meter.

* Included PR number in CHANGELOG

* Update contrib.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* use predeclared constant regex

* Add comment about how/when Version() string is updated

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
evantorrie and MrAlias committed Aug 16, 2020
1 parent 9a03b4b commit df25cc0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Added

- Top-level `Version()` and `SemVersion()` functions defining the current version of the contrib package. (#225)

## [0.10.1] - 2020-08-13

### Added
Expand Down
28 changes: 28 additions & 0 deletions contrib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package contrib contains common values used across all
// instrumentation, exporter, and detector contributions.
package contrib // import "go.opentelemetry.io/contrib"

// Version is the current release version of OpenTelemetry Contrib in use.
func Version() string {
return "0.10.1"
// This string is updated by the pre_release.sh script during release
}

// SemVersion is the semantic version to be supplied to tracer/meter creation.
func SemVersion() string {
return "semver:" + Version()
}
9 changes: 9 additions & 0 deletions pre_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ else
CONTRIB_TAG=${OTEL_TAG} # if contrib_tag not specified, but OTEL_TAG is, then set it to OTEL_TAG
fi

# Get version for contrib.go
OTEL_CONTRIB_VERSION=$(echo "${CONTRIB_TAG}" | egrep -o "${SEMVER_REGEX}")
# Strip leading v
OTEL_CONTRIB_VERSION="${OTEL_CONTRIB_VERSION#v}"

cd "$(dirname "$0")"

if ! git diff --quiet; then \
Expand All @@ -97,6 +102,10 @@ if ! git diff --quiet; then \
exit 1
fi

# Update contrib.go version definition
sed -i .bak "s/\(return \"\)[0-9]*\.[0-9]*\.[0-9]*\"/\1${OTEL_CONTRIB_VERSION}\"/" ./contrib.go
rm -f ./contrib.go.bak

declare -r BRANCH_NAME=pre_release_${CONTRIB_TAG}

patch_gomods() {
Expand Down

0 comments on commit df25cc0

Please sign in to comment.