From 1795cf157352ec892621c6fb035232b56c3d63aa Mon Sep 17 00:00:00 2001 From: Javier Palomo Date: Tue, 20 Jul 2021 11:31:40 +0200 Subject: [PATCH] Prepare CI for our internal release train (#828) * Drone: trigger on weekly release branches * Update the image-tag to include the branch name on non-tags * tools/image-tag: use bash This requires bash to be installed in the alpine/git image docker run --rm -it --entrypoint /bin/sh alpine/git /git # bash /bin/sh: bash: not found /git # apk --update --no-cache add bash fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz (1/2) Installing readline (8.1.0-r0) (2/2) Installing bash (5.1.0-r0) Executing bash-5.1.0-r0.post-install Executing busybox-1.32.1-r6.trigger OK: 27 MiB in 33 packages /git # ^C * Add CHANGELOG entry --- .drone/drone.yml | 12 ++++++++++++ CHANGELOG.md | 1 + tools/image-tag | 16 +++++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 954faaf53b9..5cfb80212d7 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -11,6 +11,7 @@ steps: - name: image-tag image: alpine/git commands: + - apk --update --no-cache add bash - git fetch origin --tags - echo $(./tools/image-tag) > .tags @@ -36,6 +37,8 @@ trigger: ref: - refs/heads/main - refs/tags/** + - refs/heads/r? # For weekly release + - refs/heads/r?? # For weekly release --- ## AMD64 ## @@ -50,6 +53,7 @@ steps: - name: image-tag image: alpine/git commands: + - apk --update --no-cache add bash - git fetch origin --tags - echo $(./tools/image-tag)-amd64 > .tags @@ -90,6 +94,8 @@ trigger: ref: - refs/heads/main - refs/tags/v* + - refs/heads/r? # For weekly release + - refs/heads/r?? # For weekly release --- ## ARM64 ## @@ -104,6 +110,7 @@ steps: - name: image-tag image: alpine/git commands: + - apk --update --no-cache add bash - git fetch origin --tags - echo $(./tools/image-tag)-arm64 > .tags @@ -144,6 +151,8 @@ trigger: ref: - refs/heads/main - refs/tags/v* + - refs/heads/r? # For weekly release + - refs/heads/r?? # For weekly release --- ## MANIFEST ## @@ -158,6 +167,7 @@ steps: - name: image-tag image: alpine/git commands: + - apk --update --no-cache add bash - git fetch origin --tags - echo $(./tools/image-tag) > .tags @@ -189,6 +199,8 @@ trigger: ref: - refs/heads/main - refs/tags/v* + - refs/heads/r? # For weekly release + - refs/heads/r?? # For weekly release --- kind: secret diff --git a/CHANGELOG.md b/CHANGELOG.md index 8099c8d5054..87f55d008b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * [ENHANCEMENT] Add `-config.expand-env` cli flag to support environment variables expansion in config file. [#796](https://github.com/grafana/tempo/pull/796) (@Ashmita152) * [ENHANCEMENT] Emit traces for ingester flush operations. [#812](https://github.com/grafana/tempo/pull/812) (@bboreham) * [ENHANCEMENT] Add retry middleware in query-frontend. [#814](https://github.com/grafana/tempo/pull/814) (@kvrhdn) +* [CHANGE] Docker images are now prefixed by their branch name [#828](https://github.com/grafana/tempo/pull/828) (@jvrplmlmn) ## v1.0.1 diff --git a/tools/image-tag b/tools/image-tag index e629cb07b61..d4f8ac7021a 100755 --- a/tools/image-tag +++ b/tools/image-tag @@ -1,15 +1,21 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail -SHA="$(git rev-parse --short HEAD)" +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. +# We are forcing to 7 here, as we are doing for grafana/grafana as well. +SHA=$(git rev-parse --short=7 HEAD | head -c7) + +# If not a tag, use branch-hash else use tag +TAG=$((git describe --exact-match 2> /dev/null || echo "") | sed 's/v//g') -# If tag, use tag -TAG=$( (git describe --exact-match 2> /dev/null || echo "") | sed 's/v//g') if [ -z "$TAG" ] then - echo ${SHA} + echo ${BRANCH}-${SHA}${WIP} else echo ${TAG} fi