diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 00000000000..f56f67aa42a --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,36 @@ +# This workflow automatically updates VERSION file in repo if any change is pushed to main branch. It performs below steps: +# 1. Checks out the repo with depth 0 for full history. +# 2. Runs make command to update VERSION file with the latest tag +# 3. Commit and push updated VERSION file + +name: Update VERSION File + +on: + push: + branches: + - main + +jobs: + update-version-file: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Update VERSION file + run: make update-version + + - name: Commit and push changes + run: | + if [ -n "$(git status --porcelain VERSION)" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add VERSION + git commit -m "Update VERSION file to latest tag" + git push + else + echo "No changes to VERSION file." + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index e2f98cea412..bf8adc454f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## main / unreleased - +* [ENHANCEMENT] Send semver version in api/stattus/buildinfo for cloud deployments [#4110](https://github.com/grafana/tempo/pull/4110) [@Aki0x137] * [ENHANCEMENT] Speedup DistinctValue collector and exit early for ingesters [#4104](https://github.com/grafana/tempo/pull/4104) (@electron0zero) * [ENHANCEMENT] Add disk caching in ingester SearchTagValuesV2 for completed blocks [#4069](https://github.com/grafana/tempo/pull/4069) (@electron0zero) * [BUGFIX] Replace hedged requests roundtrips total with a counter. [#4063](https://github.com/grafana/tempo/pull/4063) [#4078](https://github.com/grafana/tempo/pull/4078) (@galalen) diff --git a/Makefile b/Makefile index 0d409e43ed3..5a98f5d84df 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,11 @@ help: ## Display this help .DEFAULT_GOAL:=help +# Get the latest tag and store it in VERSION file +update-version: + @latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \ + echo $$latest_tag > VERSION; \ + # Version number VERSION=$(shell ./tools/image-tag | cut -d, -f 1) diff --git a/VERSION b/VERSION new file mode 100644 index 00000000000..8a965c11682 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v2.6.0 diff --git a/integration/util/util.go b/integration/util/util.go index d548f59dbdb..cc259d50878 100644 --- a/integration/util/util.go +++ b/integration/util/util.go @@ -592,6 +592,11 @@ func CallBuildinfo(t *testing.T, svc *e2e.HTTPService) { _, ok := jsonResponse[key] require.True(t, ok) } + + version, ok := jsonResponse["version"].(string) + require.True(t, ok) + require.Regexp(t, `^v?(\d+\.)?(\d+\.)?(\d+)$`, version) + defer res.Body.Close() } diff --git a/tools/image-tag b/tools/image-tag index d4f8ac7021a..2afbdb39601 100755 --- a/tools/image-tag +++ b/tools/image-tag @@ -4,6 +4,27 @@ set -o errexit set -o nounset set -o pipefail +REPO_ROOT=$(git rev-parse --show-toplevel) + +is_valid_semver() { + local version=$1 + # regex taken from https://semver.org/ + if [[ $version =~ ^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ ]] ;then + return 1 + else + return 0 + fi +} + +# Check if there is a VERSION file +if [ -f "${REPO_ROOT}/VERSION" ]; then + VERSION=$(cat "${REPO_ROOT}/VERSION" ) + if is_valid_semver "$VERSION"; then + echo "$VERSION" + exit 0 + fi +fi + WIP=$(git diff --quiet || echo '-WIP') BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's#/#-#g') # When 7 chars are not enough to be unique, git automatically uses more.