Skip to content

Commit 1a60a34

Browse files
committed
[v11.2.x] CI: Support more version formats in publishing (#94749)
CI: Support more version formats in publishing (#94575) * cleanup dead code * add tests and rewrite publish grafanacom steps to reuse * add pkg/build tests; don't upload CDN assets on grafana releases (cherry picked from commit 7a2edd3) (cherry picked from commit 39d9542f7f178dc7fb543d3f5429e401585b9204)
1 parent 5ddc329 commit 1a60a34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1052
-5043
lines changed

.drone.yml

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,10 @@ steps:
7171
- echo $DRONE_RUNNER_NAME
7272
image: alpine:3.20.3
7373
name: identify-runner
74-
- commands:
75-
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
76-
depends_on: []
77-
environment:
78-
CGO_ENABLED: 0
79-
image: golang:1.23.1-alpine
80-
name: compile-build-cmd
8174
- commands:
8275
- go install github.com/bazelbuild/buildtools/buildifier@latest
8376
- buildifier --lint=warn -mode=check -r .
84-
depends_on:
85-
- compile-build-cmd
77+
depends_on: []
8678
image: golang:1.23.1-alpine
8779
name: lint-starlark
8880
trigger:
@@ -1278,13 +1270,6 @@ platform:
12781270
os: linux
12791271
services: []
12801272
steps:
1281-
- commands:
1282-
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
1283-
depends_on: []
1284-
environment:
1285-
CGO_ENABLED: 0
1286-
image: golang:1.23.1-alpine
1287-
name: compile-build-cmd
12881273
- commands:
12891274
- apt-get update -yq && apt-get install shellcheck
12901275
- shellcheck -e SC1071 -e SC2162 scripts/**/*.sh
@@ -3434,31 +3419,32 @@ steps:
34343419
- |2-
34353420
34363421
bash -c '
3422+
IMAGE_TAG=$(echo "$${TAG}" | sed -e "s/+/-/g")
34373423
debug=
34383424
if [[ -n $${DRY_RUN} ]]; then debug=echo; fi
34393425
docker login -u $${DOCKER_USER} -p $${DOCKER_PASSWORD}
34403426
34413427
# Push the grafana-image-tags images
3442-
$$debug docker push grafana/grafana-image-tags:$${TAG}-amd64
3443-
$$debug docker push grafana/grafana-image-tags:$${TAG}-arm64
3444-
$$debug docker push grafana/grafana-image-tags:$${TAG}-armv7
3445-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-amd64
3446-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-arm64
3447-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3428+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-amd64
3429+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-arm64
3430+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
3431+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64
3432+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64
3433+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
34483434
34493435
# Create the grafana manifests
3450-
$$debug docker manifest create grafana/grafana:${TAG} grafana/grafana-image-tags:$${TAG}-amd64 grafana/grafana-image-tags:$${TAG}-arm64 grafana/grafana-image-tags:$${TAG}-armv7
3436+
$$debug docker manifest create grafana/grafana:${TAG} grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
34513437
3452-
$$debug docker manifest create grafana/grafana:${TAG}-ubuntu grafana/grafana-image-tags:$${TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3438+
$$debug docker manifest create grafana/grafana:${TAG}-ubuntu grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
34533439
34543440
# Push the grafana manifests
3455-
$$debug docker manifest push grafana/grafana:$${TAG}
3456-
$$debug docker manifest push grafana/grafana:$${TAG}-ubuntu
3441+
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}
3442+
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}-ubuntu
34573443
34583444
# if LATEST is set, then also create & push latest
34593445
if [[ -n $${LATEST} ]]; then
3460-
$$debug docker manifest create grafana/grafana:latest grafana/grafana-image-tags:$${TAG}-amd64 grafana/grafana-image-tags:$${TAG}-arm64 grafana/grafana-image-tags:$${TAG}-armv7
3461-
$$debug docker manifest create grafana/grafana:latest-ubuntu grafana/grafana-image-tags:$${TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3446+
$$debug docker manifest create grafana/grafana:latest grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
3447+
$$debug docker manifest create grafana/grafana:latest-ubuntu grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
34623448
34633449
$$debug docker manifest push grafana/grafana:latest
34643450
$$debug docker manifest push grafana/grafana:latest-ubuntu
@@ -3565,31 +3551,32 @@ steps:
35653551
- |2-
35663552
35673553
bash -c '
3554+
IMAGE_TAG=$(echo "$${TAG}" | sed -e "s/+/-/g")
35683555
debug=
35693556
if [[ -n $${DRY_RUN} ]]; then debug=echo; fi
35703557
docker login -u $${DOCKER_USER} -p $${DOCKER_PASSWORD}
35713558
35723559
# Push the grafana-image-tags images
3573-
$$debug docker push grafana/grafana-image-tags:$${TAG}-amd64
3574-
$$debug docker push grafana/grafana-image-tags:$${TAG}-arm64
3575-
$$debug docker push grafana/grafana-image-tags:$${TAG}-armv7
3576-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-amd64
3577-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-arm64
3578-
$$debug docker push grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3560+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-amd64
3561+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-arm64
3562+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
3563+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64
3564+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64
3565+
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
35793566
35803567
# Create the grafana manifests
3581-
$$debug docker manifest create grafana/grafana:${TAG} grafana/grafana-image-tags:$${TAG}-amd64 grafana/grafana-image-tags:$${TAG}-arm64 grafana/grafana-image-tags:$${TAG}-armv7
3568+
$$debug docker manifest create grafana/grafana:${TAG} grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
35823569
3583-
$$debug docker manifest create grafana/grafana:${TAG}-ubuntu grafana/grafana-image-tags:$${TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3570+
$$debug docker manifest create grafana/grafana:${TAG}-ubuntu grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
35843571
35853572
# Push the grafana manifests
3586-
$$debug docker manifest push grafana/grafana:$${TAG}
3587-
$$debug docker manifest push grafana/grafana:$${TAG}-ubuntu
3573+
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}
3574+
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}-ubuntu
35883575
35893576
# if LATEST is set, then also create & push latest
35903577
if [[ -n $${LATEST} ]]; then
3591-
$$debug docker manifest create grafana/grafana:latest grafana/grafana-image-tags:$${TAG}-amd64 grafana/grafana-image-tags:$${TAG}-arm64 grafana/grafana-image-tags:$${TAG}-armv7
3592-
$$debug docker manifest create grafana/grafana:latest-ubuntu grafana/grafana-image-tags:$${TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${TAG}-ubuntu-armv7
3578+
$$debug docker manifest create grafana/grafana:latest grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
3579+
$$debug docker manifest create grafana/grafana:latest-ubuntu grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
35933580
35943581
$$debug docker manifest push grafana/grafana:latest
35953582
$$debug docker manifest push grafana/grafana:latest-ubuntu
@@ -3681,7 +3668,8 @@ steps:
36813668
image: golang:1.23.1-alpine
36823669
name: compile-build-cmd
36833670
- commands:
3684-
- ./bin/build artifacts packages --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}
3671+
- ./bin/build artifacts packages --artifacts-editions=oss --tag $${DRONE_TAG} --src-bucket
3672+
$${PRERELEASE_BUCKET}
36853673
depends_on:
36863674
- compile-build-cmd
36873675
environment:
@@ -3691,19 +3679,6 @@ steps:
36913679
from_secret: prerelease_bucket
36923680
image: grafana/grafana-ci-deploy:1.3.3
36933681
name: publish-artifacts
3694-
- commands:
3695-
- ./bin/build artifacts static-assets --tag ${DRONE_TAG} --static-asset-editions=grafana-oss
3696-
depends_on:
3697-
- compile-build-cmd
3698-
environment:
3699-
GCP_KEY:
3700-
from_secret: gcp_grafanauploads_base64
3701-
PRERELEASE_BUCKET:
3702-
from_secret: prerelease_bucket
3703-
STATIC_ASSET_EDITIONS:
3704-
from_secret: static_asset_editions
3705-
image: grafana/grafana-ci-deploy:1.3.3
3706-
name: publish-static-assets
37073682
- commands:
37083683
- ./bin/build artifacts storybook --tag ${DRONE_TAG}
37093684
depends_on:
@@ -3723,7 +3698,6 @@ steps:
37233698
-f latest=$${LATEST} --repo=grafana/grafana release-pr.yml
37243699
depends_on:
37253700
- publish-artifacts
3726-
- publish-static-assets
37273701
environment:
37283702
GH_CLI_URL: https://github.com/cli/cli/releases/download/v2.50.0/gh_2.50.0_linux_amd64.tar.gz
37293703
GITHUB_TOKEN:
@@ -6013,6 +5987,6 @@ kind: secret
60135987
name: gcr_credentials
60145988
---
60155989
kind: signature
6016-
hmac: e618274ea7a8bfbf3d5e151d459348aa9382fe63fe7fef76c997db3cba74779f
5990+
hmac: dc30a3a00ee542fb289da36ef6db4274684db4533c472f7f903468919d1046ac
60175991

60185992
...

pkg/build/cmd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"strconv"
1212
"strings"
1313
"time"
14+
15+
"github.com/urfave/cli/v2"
1416
)
1517

1618
const (
@@ -30,6 +32,12 @@ func logError(message string, err error) int {
3032
return 1
3133
}
3234

35+
func RunCmdCLI(c *cli.Context) error {
36+
os.Exit(RunCmd())
37+
38+
return nil
39+
}
40+
3341
// RunCmd runs the build command and returns the exit code
3442
func RunCmd() int {
3543
opts := BuildOptsFromFlags()

pkg/build/cmd/argcount_wrapper.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@ package main
22

33
import "github.com/urfave/cli/v2"
44

5-
// ArgCountWrapper will cause the action to fail if there were not exactly `num` args provided.
6-
func ArgCountWrapper(num int, action cli.ActionFunc) cli.ActionFunc {
7-
return func(ctx *cli.Context) error {
8-
if ctx.NArg() != num {
9-
if err := cli.ShowSubcommandHelp(ctx); err != nil {
10-
return cli.Exit(err.Error(), 1)
11-
}
12-
return cli.Exit("", 1)
13-
}
14-
15-
return action(ctx)
16-
}
17-
}
18-
195
// ArgCountWrapper will cause the action to fail if there were more than `num` args provided.
206
func MaxArgCountWrapper(max int, action cli.ActionFunc) cli.ActionFunc {
217
return func(ctx *cli.Context) error {

pkg/build/cmd/buildbackend.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

pkg/build/cmd/builddocker.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/build/cmd/buildfrontend.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)