Skip to content
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

Output unadorned version tag for releases #862

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
- git status --porcelain --untracked-files=no
- git diff --no-ext-diff --quiet
- ./scripts/version
- '{ echo -n latest, ; ./scripts/version ; } > .tags'
- ./scripts/generate-tags > .tags
- make build
depends_on:
- deps
Expand Down Expand Up @@ -149,7 +149,7 @@ steps:
ref:
- refs/tags/v*.*.*
- commands:
- echo "latest-browser,$(./scripts/version)-browser" > .tags
- ./scripts/generate-tags browser > .tags
depends_on:
- docker publish (release)
image: ghcr.io/grafana/grafana-build-tools:v0.23.0
Expand Down Expand Up @@ -350,6 +350,6 @@ kind: secret
name: gpg_private_key
---
kind: signature
hmac: d4db61b261c83fd65b96a3ea5bec1f3a1d8a5a4e7e80619c8573e6fd5dc6bbbd
hmac: f6c6e83ee34a0f724b7e3e0ca4fad4e202fee749da8997dc30aeaddae3ec9a9e

...
14 changes: 7 additions & 7 deletions scripts/configs/drone/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ local docker_step(tag, os, arch, version='', with_browser=false) =

local docker_build(os, arch, version='', with_browser=false) =
local step = if with_browser then
'docker build (with browser)'
else
'docker build';
'docker build (with browser)'
else
'docker build';
docker_step(step, os, arch, version, with_browser)
+ dependsOn([ 'build' ]);

Expand All @@ -111,10 +111,10 @@ local docker_publish(repo, auth, tag, os, arch, version='') =
+ { settings: { repo: repo, dry_run: 'false' } + auth }
+ dependsOn([ 'test', 'docker build' ]);

local docker_publish_with_browser(repo, auth, tag, os, arch) =
local docker_publish_with_browser(repo, auth, tag, os, arch) =
docker_step('docker publish (with browser) to ' + tag, os, arch, '', true)
+ { settings: { repo: repo, dry_run: 'false' } + auth }
+ dependsOn([ 'docker publish (with browser) tags' ]); // step to update .tags file with browser-specific image tags
+ dependsOn([ 'docker publish (with browser) tags' ]); // step to update .tags file with browser-specific image tags

[
pipeline('build', [
Expand All @@ -138,7 +138,7 @@ local docker_publish(repo, auth, tag, os, arch, version='') =
'git status --porcelain --untracked-files=no',
'git diff --no-ext-diff --quiet', // fail if the workspace has modified files
'./scripts/version',
'{ echo -n latest, ; ./scripts/version ; } > .tags', // save version in special file for docker plugin
'./scripts/generate-tags > .tags', // save version in special file for docker plugin
'make build',
],
go_tools_image,
Expand Down Expand Up @@ -191,7 +191,7 @@ local docker_publish(repo, auth, tag, os, arch, version='') =
step(
'docker publish (with browser) tags',
[
'echo "latest-browser,$(./scripts/version)-browser" > .tags', // use with-browser tags for docker plugin
'./scripts/generate-tags browser > .tags',
],
go_tools_image,
)
Expand Down
24 changes: 24 additions & 0 deletions scripts/generate-tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e
set -u

# If an optional suffix is provided, append it to all the tags as `-suffix`.
# Note that this breaks the semver format, because appending -foobar means it's
# a pre-release version, not a "flavor" as some people claim. The more
# appropriate way to express this would be to use `+suffix`, but we'll defer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting to add further context - Docker tags don't support + in the character set currently:

# that until we have fixed the different places where this might be used.
suffix=${1:+-}${1:-}

rootdir=$(git rev-parse --show-toplevel)
version=$("${rootdir}/scripts/version")

version_base=$(echo "${version}" | cut -d- -f1)
version_seq=$(echo "${version}" | cut -d- -f2)
mem marked this conversation as resolved.
Show resolved Hide resolved

printf "%s," "latest${suffix}"
printf "%s" "${version}${suffix}"
if [ "${version_seq}" = "0" ]; then
# Strip the additional -0-* suffix to generate a additional tag that looks like vX.Y.Z
printf ",%s" "${version_base}${suffix}"
fi