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

Build: Remove ./tools/fetch-tags invocation from Makefile #8849

Closed
wants to merge 6 commits into from
Closed
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
64 changes: 42 additions & 22 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ local gpg_private_key = secret('gpg_private_key', 'infra/data/ci/packages-publis
local updater_config_template = secret('updater_config_template', 'secret/data/common/loki_ci_autodeploy', 'updater-config-template.json');
local helm_chart_auto_update_config_template = secret('helm-chart-update-config-template', 'secret/data/common/loki-helm-chart-auto-update', 'on-loki-release-config.json');

local build_image_name = 'grafana/loki-build-image:%s' % build_image_version;

local run(name, commands, env={}) = {
name: name,
image: 'grafana/loki-build-image:%s' % build_image_version,
image: build_image_name,
commands: commands,
environment: env,
};
Expand All @@ -67,6 +69,14 @@ local make(target, container=true, args=[]) = run(target, [
] + args),
]);

local fetch_tags = {
name: 'fetch-tags',
image: build_image_name,
commands: [
'git fetch origin --tags',
],
};

local docker(arch, app) = {
name: '%s-image' % if $.settings.dry_run then 'build-' + app else 'publish-' + app,
image: if arch == 'arm' then 'plugins/docker:linux-arm' else 'plugins/docker',
Expand Down Expand Up @@ -124,15 +134,17 @@ local arch_image(arch, tags='') = {
os: 'linux',
arch: arch,
},
steps: [{
name: 'image-tag',
image: 'alpine',
commands: [
'apk add --no-cache bash git',
'git fetch origin --tags',
'echo $(./tools/image-tag)-%s > .tags' % arch,
] + if tags != '' then ['echo ",%s" >> .tags' % tags] else [],
}],
steps: [
fetch_tags,
{
name: 'image-tag',
depends_on: ['fetch-tags'],
image: build_image_name,
commands: [
'echo $(./tools/image-tag)-%s > .tags' % arch,
] + if tags != '' then ['echo ",%s" >> .tags' % tags] else [],
},
],
};

local promtail_win() = pipeline('promtail-windows') {
Expand All @@ -142,6 +154,13 @@ local promtail_win() = pipeline('promtail-windows') {
version: '1809',
},
steps: [
{
name: 'fetch-tags',
image: 'golang:1.19-windowsservercore-1809',
commands: [
'git fetch origin --tags',
],
},
{
name: 'identify-runner',
image: 'golang:1.19-windowsservercore-1809',
Expand Down Expand Up @@ -645,16 +664,15 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
depends_on: ['manifest'],
image_pull_secrets: [pull_secret.name],
steps: [
fetch_tags,
{
name: 'prepare-updater-config',
image: 'alpine',
image: build_image_name,
environment: {
MAJOR_MINOR_VERSION_REGEXP: '([0-9]+\\.[0-9]+)',
RELEASE_TAG_REGEXP: '^([0-9]+\\.[0-9]+\\.[0-9]+)$',
},
commands: [
'apk add --no-cache bash git',
Copy link
Contributor

Choose a reason for hiding this comment

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

i will cause an issue that ./tools/image-tag won't be executed becuse it uses bash

'git fetch origin --tags',
'echo $(./tools/image-tag) > .tag',
'export RELEASE_TAG=$(cat .tag)',
// if the tag matches the pattern `D.D.D` then RELEASE_NAME="D-D-x", otherwise RELEASE_NAME="next"
Expand All @@ -668,7 +686,7 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
settings: {
config_template: { from_secret: updater_config_template.name },
},
depends_on: ['clone'],
depends_on: ['fetch-tags'],
},
{
name: 'trigger',
Expand All @@ -690,25 +708,22 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
ref: ['refs/tags/v*'],
},
steps: [
fetch_tags,
{
name: 'check-version-is-latest',
image: 'alpine',
image: build_image_name,
when: onTag,
commands: [
'apk add --no-cache bash git',
'git fetch --tags',
"latest_version=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1 | sed 's/v//g')",
'RELEASE_TAG=$(./tools/image-tag)',
'if [ "$RELEASE_TAG" != "$latest_version" ]; then echo "Current version $RELEASE_TAG is not the latest version of Loki. The latest version is $latest_version" && exit 78; fi',
],
},
{
name: 'prepare-helm-chart-update-config',
image: 'alpine',
image: build_image_name,
depends_on: ['check-version-is-latest'],
commands: [
'apk add --no-cache bash git',
'git fetch origin --tags',
'RELEASE_TAG=$(./tools/image-tag)',
'echo $PLUGIN_CONFIG_TEMPLATE > %s' % configFileName,
// replace placeholders with RELEASE TAG
Expand Down Expand Up @@ -780,6 +795,7 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
],
// Package and test the packages
steps: [
fetch_tags,
run('write-key',
commands=['printf "%s" "$NFPM_SIGNING_KEY" > $NFPM_SIGNING_KEY_FILE'],
env={
Expand Down Expand Up @@ -824,16 +840,20 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
GITHUB_TOKEN: { from_secret: github_secret.name },
NFPM_PASSPHRASE: { from_secret: gpg_passphrase.name },
NFPM_SIGNING_KEY_FILE: '/drone/src/private-key.key',
}) { when: { event: ['tag'] } },
}) {
when: { event: ['tag'] },
depends_on: ['fetch-tags'],
},
],
},
pipeline('docker-driver') {
trigger+: onTagOrMain,
steps: [
fetch_tags,
{
name: 'build and push',
image: 'grafana/loki-build-image:%s' % build_image_version,
depends_on: ['clone'],
depends_on: ['fetch-tags'],
environment: {
DOCKER_USERNAME: { from_secret: docker_username_secret.name },
DOCKER_PASSWORD: { from_secret: docker_password_secret.name },
Expand Down
Loading