From 7e2238cf6f1413171bb6d0ac8639d6e4e896b60b Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Thu, 1 Sep 2022 15:43:40 +0300 Subject: [PATCH] CI: Generate Grafana version (and metadata) when the build binary is built (#54393) * Add GenerateVersions as BeforeFunc * Delete gen-version * Fix lint * Get build id from env var --- .drone.yml | 157 +-------------------- pkg/build/cmd/genversions.go | 97 +++++++++++++ pkg/build/cmd/main.go | 2 +- pkg/build/config/version.go | 9 ++ pkg/build/config/version_mode.go | 12 ++ scripts/drone/events/release.star | 6 +- scripts/drone/pipelines/build.star | 2 - scripts/drone/pipelines/docs.star | 2 - scripts/drone/pipelines/publish.star | 2 - scripts/drone/pipelines/test_backend.star | 2 - scripts/drone/pipelines/test_frontend.star | 2 - scripts/drone/pipelines/windows.star | 1 - scripts/drone/steps/lib.star | 28 +--- 13 files changed, 128 insertions(+), 194 deletions(-) create mode 100644 pkg/build/cmd/genversions.go diff --git a/.drone.yml b/.drone.yml index 95b7d96e726..2d15d87280c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -66,12 +66,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - yarn install --immutable depends_on: @@ -158,12 +152,6 @@ steps: CGO_ENABLED: 0 image: golang:1.17 name: compile-build-cmd -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -269,12 +257,6 @@ steps: CGO_ENABLED: 0 image: golang:1.17 name: compile-build-cmd -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -312,7 +294,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -321,7 +302,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -330,7 +310,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -339,7 +318,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition oss depends_on: - - gen-version - yarn-install environment: null image: grafana/build-container:1.5.9 @@ -638,12 +616,6 @@ steps: - echo $DRONE_RUNNER_NAME image: alpine:3.15.6 name: identify-runner -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - yarn install --immutable depends_on: @@ -673,7 +645,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -737,12 +708,6 @@ steps: - echo $DRONE_RUNNER_NAME image: alpine:3.15.6 name: identify-runner -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - yarn install --immutable depends_on: @@ -772,7 +737,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -837,12 +801,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - yarn install --immutable depends_on: @@ -926,12 +884,6 @@ steps: CGO_ENABLED: 0 image: golang:1.17 name: compile-build-cmd -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -1036,12 +988,6 @@ steps: CGO_ENABLED: 0 image: golang:1.17 name: compile-build-cmd -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -1105,7 +1051,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -1114,7 +1059,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -1123,7 +1067,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -1132,7 +1075,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition oss depends_on: - - gen-version - yarn-install environment: GRAFANA_API_KEY: @@ -1578,7 +1520,6 @@ steps: - gcloud auth activate-service-account --key-file=gcpkey.json - rm gcpkey.json - cp C:\App\nssm-2.24.zip . - - .\grabpl.exe gen-version --build-id $$env:DRONE_BUILD_NUMBER - .\grabpl.exe windows-installer --edition oss --build-id $$env:DRONE_BUILD_NUMBER - $$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0] - gsutil cp $$fname gs://grafana-downloads/oss/main/ @@ -1666,12 +1607,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd depends_on: [] @@ -1687,7 +1622,7 @@ steps: - ./bin/grabpl publish packages --edition oss --gcp-key /tmp/gcpkey.json --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version + - grabpl environment: GCP_KEY: from_secret: gcp_key @@ -1778,12 +1713,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -1815,7 +1744,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition oss ${DRONE_TAG} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -1824,7 +1752,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition oss ${DRONE_TAG} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -1833,7 +1760,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss ${DRONE_TAG} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -1842,7 +1768,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition oss depends_on: - - gen-version - yarn-install environment: GRAFANA_API_KEY: @@ -2088,12 +2013,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -2337,7 +2256,6 @@ steps: - gcloud auth activate-service-account --key-file=gcpkey.json - rm gcpkey.json - cp C:\App\nssm-2.24.zip . - - .\grabpl.exe gen-version ${DRONE_TAG} - .\grabpl.exe windows-installer --edition oss ${DRONE_TAG} - $$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0] - gsutil cp $$fname gs://%PRERELEASE_BUCKET%/artifacts/downloads/${DRONE_TAG}/oss/release/ @@ -2437,12 +2355,6 @@ steps: - init-enterprise image: grafana/build-container:1.5.9 name: yarn-install -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - init-enterprise - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -2456,7 +2368,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition enterprise ${DRONE_TAG} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -2465,7 +2376,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition enterprise ${DRONE_TAG} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -2474,7 +2384,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition enterprise ${DRONE_TAG} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -2483,7 +2392,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition enterprise depends_on: - - gen-version - yarn-install environment: GRAFANA_API_KEY: @@ -2493,7 +2401,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition enterprise2 ${DRONE_TAG} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -2796,12 +2703,6 @@ steps: - init-enterprise image: grafana/build-container:1.5.9 name: yarn-install -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - init-enterprise - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -3108,7 +3009,6 @@ steps: - gcloud auth activate-service-account --key-file=gcpkey.json - rm gcpkey.json - cp C:\App\nssm-2.24.zip . - - .\grabpl.exe gen-version ${DRONE_TAG} - .\grabpl.exe windows-installer --edition enterprise ${DRONE_TAG} - $$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0] - gsutil cp $$fname gs://%PRERELEASE_BUCKET%/artifacts/downloads/${DRONE_TAG}/enterprise/release/ @@ -3585,16 +3485,10 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - ./bin/grabpl publish packages --edition oss --gcp-key /tmp/gcpkey.json ${DRONE_TAG} depends_on: - - gen-version + - grabpl environment: GCP_KEY: from_secret: gcp_key @@ -3618,7 +3512,7 @@ steps: image: grafana/grafana-ci-deploy:1.3.3 name: publish-grafanacom-oss - depends_on: - - gen-version + - grabpl failure: ignore image: us.gcr.io/kubernetes-dev/package-publish:latest name: publish-linux-packages @@ -3670,17 +3564,11 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version ${DRONE_TAG} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - ./bin/grabpl publish packages --edition enterprise --gcp-key /tmp/gcpkey.json ${DRONE_TAG} depends_on: - - gen-version + - grabpl environment: GCP_KEY: from_secret: gcp_key @@ -3704,7 +3592,7 @@ steps: image: grafana/grafana-ci-deploy:1.3.3 name: publish-grafanacom-enterprise - depends_on: - - gen-version + - grabpl failure: ignore image: us.gcr.io/kubernetes-dev/package-publish:latest name: publish-linux-packages @@ -3794,12 +3682,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -3831,7 +3713,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -3840,7 +3721,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -3849,7 +3729,6 @@ steps: - commands: - ./bin/grabpl build-frontend-packages --jobs 8 --edition oss --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -3858,7 +3737,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition oss depends_on: - - gen-version - yarn-install environment: GRAFANA_API_KEY: @@ -4075,12 +3953,6 @@ steps: - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - grabpl - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -4398,12 +4270,6 @@ steps: - init-enterprise image: grafana/build-container:1.5.9 name: yarn-install -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - init-enterprise - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -4417,7 +4283,6 @@ steps: - commands: - ./bin/build build-backend --jobs 8 --edition enterprise --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -4426,7 +4291,6 @@ steps: - ./bin/build build-frontend --jobs 8 --edition enterprise --build-id ${DRONE_BUILD_NUMBER} depends_on: - compile-build-cmd - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -4436,7 +4300,6 @@ steps: - ./bin/grabpl build-frontend-packages --jobs 8 --edition enterprise --build-id ${DRONE_BUILD_NUMBER} depends_on: - - gen-version - yarn-install environment: NODE_OPTIONS: --max_old_space_size=8192 @@ -4445,7 +4308,6 @@ steps: - commands: - ./bin/build build-plugins --jobs 8 --edition enterprise depends_on: - - gen-version - yarn-install environment: GRAFANA_API_KEY: @@ -4456,7 +4318,6 @@ steps: - ./bin/build build-backend --jobs 8 --edition enterprise2 --build-id ${DRONE_BUILD_NUMBER} --variants linux-amd64 depends_on: - - gen-version - wire-install - compile-build-cmd image: grafana/build-container:1.5.9 @@ -4747,12 +4608,6 @@ steps: - init-enterprise image: grafana/build-container:1.5.9 name: yarn-install -- commands: - - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} - depends_on: - - init-enterprise - image: grafana/build-container:1.5.9 - name: gen-version - commands: - '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.' @@ -5253,6 +5108,6 @@ kind: secret name: packages_secret_access_key --- kind: signature -hmac: ce0208c16afae599091c3df008a9bbe3cf98bdfdd962554b722c9bc6985ad5ac +hmac: 40c8c66094bd5928aff25edef47082ff5686a0ca8c57e7d08f76eb5857103e72 ... diff --git a/pkg/build/cmd/genversions.go b/pkg/build/cmd/genversions.go new file mode 100644 index 00000000000..0a06a9f4947 --- /dev/null +++ b/pkg/build/cmd/genversions.go @@ -0,0 +1,97 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/grafana/grafana/pkg/build/config" + "github.com/grafana/grafana/pkg/build/droneutil" + "github.com/urfave/cli/v2" +) + +func GenerateVersions(c *cli.Context) error { + var metadata config.Metadata + version := "" + if c.NArg() == 1 { + version = strings.TrimPrefix(c.Args().Get(0), "v") + } else { + buildID, ok := os.LookupEnv("DRONE_BUILD_NUMBER") + if !ok { + return fmt.Errorf("unable to get DRONE_BUILD_NUMBER environmental variable") + } + var err error + version, err = config.GetGrafanaVersion(buildID, ".") + if err != nil { + return err + } + } + event, err := droneutil.GetDroneEventFromEnv() + if err != nil { + return err + } + + var releaseMode config.ReleaseMode + switch event { + case string(config.PullRequestMode): + releaseMode = config.ReleaseMode{Mode: config.PullRequestMode} + case config.Push: + mode, err := config.CheckDroneTargetBranch() + if err != nil { + return err + } + releaseMode = config.ReleaseMode{Mode: mode} + case config.Custom: + mode, err := config.CheckDroneTargetBranch() + if err != nil { + return err + } + // if there is a custom event targeting the main branch, that's an enterprise downstream build + if mode == config.MainBranch { + releaseMode = config.ReleaseMode{Mode: config.CustomMode} + } else { + releaseMode = config.ReleaseMode{Mode: mode} + } + case config.Tag, config.Promote: + mode, err := config.CheckSemverSuffix() + if err != nil { + return err + } + releaseMode = mode + } + + currentCommit, err := config.GetDroneCommit() + if err != nil { + return err + } + metadata = config.Metadata{ + GrafanaVersion: version, + ReleaseMode: releaseMode, + GrabplVersion: c.App.Version, + CurrentCommit: currentCommit, + } + + fmt.Printf("building Grafana version: %s, release mode: %+v", metadata.GrafanaVersion, metadata.ReleaseMode) + + jsonMetadata, err := json.Marshal(&metadata) + if err != nil { + return fmt.Errorf("error marshalling metadata, %w", err) + } + + const distDir = "dist" + if err := os.RemoveAll(distDir); err != nil { + return err + } + if err := os.Mkdir(distDir, 0750); err != nil { + return err + } + + // nolint:gosec + if err := os.WriteFile(filepath.Join(distDir, "version.json"), jsonMetadata, 0664); err != nil { + return err + } + + return nil +} diff --git a/pkg/build/cmd/main.go b/pkg/build/cmd/main.go index 1b8f4774f82..c9bc7d87aec 100644 --- a/pkg/build/cmd/main.go +++ b/pkg/build/cmd/main.go @@ -11,7 +11,7 @@ import ( func main() { app := cli.NewApp() - + app.Before = GenerateVersions app.Commands = cli.Commands{ { Name: "build-backend", diff --git a/pkg/build/config/version.go b/pkg/build/config/version.go index 300056fd5dd..440b08c3c7b 100644 --- a/pkg/build/config/version.go +++ b/pkg/build/config/version.go @@ -16,6 +16,7 @@ type Metadata struct { GrafanaVersion string `json:"version,omitempty"` ReleaseMode ReleaseMode `json:"releaseMode,omitempty"` GrabplVersion string `json:"grabplVersion,omitempty"` + CurrentCommit string `json:"currentCommit,omitempty"` } type ReleaseMode struct { @@ -170,3 +171,11 @@ func CheckSemverSuffix() (ReleaseMode, error) { return ReleaseMode{Mode: TagMode}, nil } } + +func GetDroneCommit() (string, error) { + commit := strings.TrimSpace(os.Getenv("DRONE_COMMIT")) + if commit == "" { + return "", fmt.Errorf("the environment variable DRONE_COMMIT is missing") + } + return commit, nil +} diff --git a/pkg/build/config/version_mode.go b/pkg/build/config/version_mode.go index 1d2b14d412c..7f1c0c635ce 100644 --- a/pkg/build/config/version_mode.go +++ b/pkg/build/config/version_mode.go @@ -10,3 +10,15 @@ const ( PullRequestMode VersionMode = "pull_request" CustomMode VersionMode = "custom" ) + +const ( + Tag = "tag" + PullRequest = "pull_request" + Push = "push" + Custom = "custom" + Promote = "promote" +) + +const ( + MainBranch = "main" +) diff --git a/scripts/drone/events/release.star b/scripts/drone/events/release.star index 6cdb1fe565a..34f6589980a 100644 --- a/scripts/drone/events/release.star +++ b/scripts/drone/events/release.star @@ -3,7 +3,6 @@ load( 'disable_tests', 'clone_enterprise_step', 'download_grabpl_step', - 'gen_version_step', 'yarn_install_step', 'wire_install_step', 'init_enterprise_step', @@ -164,7 +163,6 @@ def get_steps(edition, ver_mode): init_steps = [ identify_runner_step(), download_grabpl_step(), - gen_version_step(ver_mode), verify_gen_cue_step(edition), wire_install_step(), yarn_install_step(), @@ -312,7 +310,7 @@ def get_enterprise_pipelines(trigger, ver_mode): init_enterprise_step(ver_mode), compile_build_cmd(edition), ] - for step in [wire_install_step(), yarn_install_step(), gen_version_step(ver_mode), verify_gen_cue_step(edition)]: + for step in [wire_install_step(), yarn_install_step(), verify_gen_cue_step(edition)]: step.update(deps_on_clone_enterprise_step) init_steps.extend([step]) @@ -392,7 +390,6 @@ def publish_packages_pipeline(): } oss_steps = [ download_grabpl_step(), - gen_version_step(ver_mode='release'), publish_packages_step(edition='oss', ver_mode='release'), publish_grafanacom_step(edition='oss', ver_mode='release'), publish_linux_packages_step(edition='oss'), @@ -400,7 +397,6 @@ def publish_packages_pipeline(): enterprise_steps = [ download_grabpl_step(), - gen_version_step(ver_mode='release'), publish_packages_step(edition='enterprise', ver_mode='release'), publish_grafanacom_step(edition='enterprise', ver_mode='release'), publish_linux_packages_step(edition='enterprise'), diff --git a/scripts/drone/pipelines/build.star b/scripts/drone/pipelines/build.star index a087a57cc7e..f020cf0679d 100644 --- a/scripts/drone/pipelines/build.star +++ b/scripts/drone/pipelines/build.star @@ -3,7 +3,6 @@ load( 'download_grabpl_step', 'build_image', 'identify_runner_step', - 'gen_version_step', 'wire_install_step', 'yarn_install_step', 'build_backend_step', @@ -49,7 +48,6 @@ def build_e2e(trigger, ver_mode, edition): identify_runner_step(), download_grabpl_step(), compile_build_cmd(), - gen_version_step(ver_mode), verify_gen_cue_step(edition="oss"), wire_install_step(), yarn_install_step(), diff --git a/scripts/drone/pipelines/docs.star b/scripts/drone/pipelines/docs.star index b32879b8b62..8854e29b4c0 100644 --- a/scripts/drone/pipelines/docs.star +++ b/scripts/drone/pipelines/docs.star @@ -3,7 +3,6 @@ load( 'build_image', 'yarn_install_step', 'identify_runner_step', - 'gen_version_step', 'download_grabpl_step', 'lint_frontend_step', 'codespell_step', @@ -39,7 +38,6 @@ def docs_pipelines(edition, ver_mode, trigger): steps = [ download_grabpl_step(), identify_runner_step(), - gen_version_step(ver_mode), yarn_install_step(), codespell_step(), lint_docs(), diff --git a/scripts/drone/pipelines/publish.star b/scripts/drone/pipelines/publish.star index 1eeb39902b3..9d80d4a55ae 100644 --- a/scripts/drone/pipelines/publish.star +++ b/scripts/drone/pipelines/publish.star @@ -1,7 +1,6 @@ load( 'scripts/drone/steps/lib.star', 'identify_runner_step', - 'gen_version_step', 'download_grabpl_step', 'publish_packages_step', 'compile_build_cmd', @@ -15,7 +14,6 @@ load( def publish(trigger, ver_mode, edition): steps = [ download_grabpl_step(), - gen_version_step(ver_mode), compile_build_cmd(), identify_runner_step(), publish_packages_step(edition=edition, ver_mode=ver_mode), diff --git a/scripts/drone/pipelines/test_backend.star b/scripts/drone/pipelines/test_backend.star index 2f82fce1fdf..81267d8dae5 100644 --- a/scripts/drone/pipelines/test_backend.star +++ b/scripts/drone/pipelines/test_backend.star @@ -2,7 +2,6 @@ load( 'scripts/drone/steps/lib.star', 'identify_runner_step', 'download_grabpl_step', - 'gen_version_step', 'wire_install_step', 'codespell_step', 'shellcheck_step', @@ -24,7 +23,6 @@ def test_backend(trigger, ver_mode): identify_runner_step(), download_grabpl_step(), compile_build_cmd(), - gen_version_step(ver_mode), verify_gen_cue_step(edition="oss"), wire_install_step(), ] diff --git a/scripts/drone/pipelines/test_frontend.star b/scripts/drone/pipelines/test_frontend.star index 81416cae4d3..cbc5129ec3d 100644 --- a/scripts/drone/pipelines/test_frontend.star +++ b/scripts/drone/pipelines/test_frontend.star @@ -2,7 +2,6 @@ load( 'scripts/drone/steps/lib.star', 'identify_runner_step', 'download_grabpl_step', - 'gen_version_step', 'yarn_install_step', 'lint_frontend_step', 'betterer_frontend_step', @@ -19,7 +18,6 @@ def test_frontend(trigger, ver_mode): init_steps = [ identify_runner_step(), download_grabpl_step(), - gen_version_step(ver_mode), yarn_install_step(), compile_build_cmd(), ] diff --git a/scripts/drone/pipelines/windows.star b/scripts/drone/pipelines/windows.star index 14ff7afc174..c0e0f61f7f6 100644 --- a/scripts/drone/pipelines/windows.star +++ b/scripts/drone/pipelines/windows.star @@ -55,7 +55,6 @@ def windows(trigger, edition, ver_mode): 'release', ): installer_commands.extend([ - '.\\grabpl.exe gen-version {}'.format(ver_part), '.\\grabpl.exe windows-installer --edition {} {}'.format(edition, ver_part), '$$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0]', ]) diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index e36a84917b6..b7b3701c5cd 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -30,25 +30,6 @@ def slack_step(channel, template, secret): }, } - -def gen_version_step(ver_mode): - if ver_mode == 'release': - args = '${DRONE_TAG}' - else: - build_no = '${DRONE_BUILD_NUMBER}' - args = '--build-id {}'.format(build_no) - return { - 'name': 'gen-version', - 'image': build_image, - 'depends_on': [ - 'grabpl', - ], - 'commands': [ - './bin/grabpl gen-version {}'.format(args), - ], - } - - def yarn_install_step(): return { 'name': 'yarn-install', @@ -392,7 +373,6 @@ def build_backend_step(edition, ver_mode, variants=None): 'name': 'build-backend' + enterprise2_suffix(edition), 'image': build_image, 'depends_on': [ - 'gen-version', 'wire-install', 'compile-build-cmd', ], @@ -423,7 +403,6 @@ def build_frontend_step(edition, ver_mode): }, 'depends_on': [ 'compile-build-cmd', - 'gen-version', 'yarn-install', ], 'commands': cmds, @@ -452,7 +431,6 @@ def build_frontend_package_step(edition, ver_mode): 'NODE_OPTIONS': '--max_old_space_size=8192', }, 'depends_on': [ - 'gen-version', 'yarn-install', ], 'commands': cmds, @@ -484,7 +462,6 @@ def build_plugins_step(edition, ver_mode): 'image': build_image, 'environment': env, 'depends_on': [ - 'gen-version', 'yarn-install', ], 'commands': [ @@ -1014,7 +991,7 @@ def publish_packages_step(edition, ver_mode): 'name': 'publish-packages-{}'.format(edition), 'image': publish_image, 'depends_on': [ - 'gen-version', + 'grabpl', ], 'environment': { 'GRAFANA_COM_API_KEY': from_secret('grafana_api_key'), @@ -1061,7 +1038,7 @@ def publish_linux_packages_step(edition): # See https://github.com/grafana/deployment_tools/blob/master/docker/package-publish/README.md for docs on that image 'image': 'us.gcr.io/kubernetes-dev/package-publish:latest', 'depends_on': [ - 'gen-version' + 'grabpl' ], 'failure': 'ignore', # While we're testing it 'settings': { @@ -1121,7 +1098,6 @@ def get_windows_steps(edition, ver_mode): 'release', ): installer_commands.extend([ - '.\\grabpl.exe gen-version {}'.format(ver_part), '.\\grabpl.exe windows-installer --edition {} {}'.format(edition, ver_part), '$$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0]', ])