From dd15c5dc95a2e8380ed8b64a831445326d4ce46a Mon Sep 17 00:00:00 2001 From: Kevin Minehart <5140827+kminehart@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:28:03 -0600 Subject: [PATCH] [release-11.3.5] CI: Remove unused release_publisher scripts (#101156) CI: Remove unused release_publisher scripts (#101019) * Remove the unused `release_publisher` script. * Remove the "whats new check" in Drone. * Automatically set the What's New URL in releases based on the tagged version. (cherry picked from commit 49e5f77dd182d923f8e2fc89980a225daf98f162) --- .drone.yml | 47 +-- package.json | 6 +- pkg/build/cmd/grafanacom.go | 41 ++- pkg/build/cmd/grafanacom_test.go | 24 ++ pkg/build/versions/parse.go | 6 +- scripts/build/publish.sh | 18 - .../release_publisher/externalrelease.go | 71 ---- scripts/build/release_publisher/main.go | 80 ----- scripts/build/release_publisher/publisher.go | 312 ------------------ .../build/release_publisher/publisher_test.go | 201 ----------- ...nterprise-5.4.0-123pre1.linux-amd64.tar.gz | 0 ...se-5.4.0-123pre1.linux-amd64.tar.gz.sha256 | 1 - ...enterprise-5.4.0-123pre1.windows-amd64.msi | 0 ...ise-5.4.0-123pre1.windows-amd64.msi.sha256 | 1 - ...enterprise-5.4.0-123pre1.windows-amd64.zip | 0 ...ise-5.4.0-123pre1.windows-amd64.zip.sha256 | 1 - ...rafana-enterprise-5.4.0-123pre1.x86_64.rpm | 0 ...enterprise-5.4.0-123pre1.x86_64.rpm.sha256 | 1 - ...grafana-enterprise_5.4.0-123pre1_amd64.deb | 0 ...-enterprise_5.4.0-123pre1_amd64.deb.sha256 | 1 - .../drone/pipelines/whats_new_checker.star | 42 --- scripts/drone/rgm.star | 5 - 22 files changed, 60 insertions(+), 798 deletions(-) delete mode 100755 scripts/build/publish.sh delete mode 100644 scripts/build/release_publisher/externalrelease.go delete mode 100644 scripts/build/release_publisher/main.go delete mode 100644 scripts/build/release_publisher/publisher.go delete mode 100644 scripts/build/release_publisher/publisher_test.go delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz.sha256 delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi.sha256 delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip.sha256 delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm.sha256 delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb delete mode 100644 scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb.sha256 delete mode 100644 scripts/drone/pipelines/whats_new_checker.star diff --git a/.drone.yml b/.drone.yml index ba09c58bc08..8295b7fda4b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4210,51 +4210,6 @@ volumes: path: /var/run/docker.sock name: docker --- -clone: - retries: 3 -depends_on: [] -environment: - EDITION: oss -image_pull_secrets: -- gcr -- gar -kind: pipeline -name: release-whatsnew-checker -node: - type: no-parallel -platform: - arch: amd64 - os: linux -services: [] -steps: -- commands: - - go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd - depends_on: [] - environment: - CGO_ENABLED: 0 - image: golang:1.23.5-alpine - name: compile-build-cmd -- commands: - - ./bin/build whatsnew-checker - depends_on: - - compile-build-cmd - image: golang:1.23.5-alpine - name: whats-new-checker -trigger: - event: - exclude: - - promote - ref: - exclude: - - refs/tags/*-cloud* - include: - - refs/tags/v* -type: docker -volumes: -- host: - path: /var/run/docker.sock - name: docker ---- clone: retries: 3 depends_on: @@ -5733,6 +5688,6 @@ kind: secret name: gcr_credentials --- kind: signature -hmac: 7210382290a72f0ce411fd3f463d72c2dd9a1b062c7238cad35908bf2cca1794 +hmac: 7938c034ff11ec8129ef6f4874d13d32ba1b34b209715ebe8dc7ee0c3b9808bd ... diff --git a/package.json b/package.json index 8bd36662f62..2d7b377e652 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "generate-apis": "rtk-query-codegen-openapi ./scripts/generate-rtk-apis.ts" }, "grafana": { - "whatsNewUrl": "https://grafana.com/docs/grafana/next/whatsnew/whats-new-in-v11-3/", + "whatsNewUrl": "https://grafana.com/docs/grafana/next/whatsnew/whats-new-in-v%[1]s-%[2]s/", "releaseNotesUrl": "https://grafana.com/docs/grafana/next/release-notes/" }, "devDependencies": { @@ -448,8 +448,6 @@ } }, "msw": { - "workerDirectory": [ - "public" - ] + "workerDirectory": ["public"] } } diff --git a/pkg/build/cmd/grafanacom.go b/pkg/build/cmd/grafanacom.go index ab53217f7a4..cb413f697bc 100644 --- a/pkg/build/cmd/grafanacom.go +++ b/pkg/build/cmd/grafanacom.go @@ -21,6 +21,7 @@ import ( "github.com/grafana/grafana/pkg/build/gcloud/storage" "github.com/grafana/grafana/pkg/build/gcom" "github.com/grafana/grafana/pkg/build/packaging" + "github.com/grafana/grafana/pkg/build/versions" ) const grafanaAPI = "https://grafana.com/api" @@ -45,6 +46,7 @@ func GrafanaCom(c *cli.Context) error { } version := metadata.GrafanaVersion + semver := versions.ParseSemver(version) if releaseMode.Mode == config.Cronjob { gcs, err := storage.New() if err != nil { @@ -69,7 +71,13 @@ func GrafanaCom(c *cli.Context) error { if grafanaAPIKey == "" { return cli.Exit("the environment variable GRAFANA_COM_API_KEY must be set", 1) } - whatsNewURL, releaseNotesURL, err := getReleaseURLs() + + pkgjson, err := getPackageJSON() + if err != nil { + return cli.Exit(err.Error(), 1) + } + + whatsNewURL, releaseNotesURL, err := getReleaseURLs(semver, pkgjson) if err != nil { return cli.Exit(err.Error(), 1) } @@ -97,25 +105,32 @@ func GrafanaCom(c *cli.Context) error { return nil } -func getReleaseURLs() (string, string, error) { - type grafanaConf struct { - WhatsNewURL string `json:"whatsNewUrl"` - ReleaseNotesURL string `json:"releaseNotesUrl"` - } - type packageConf struct { - Grafana grafanaConf `json:"grafana"` - } +type grafanaConf struct { + WhatsNewURL string `json:"whatsNewUrl"` + ReleaseNotesURL string `json:"releaseNotesUrl"` +} + +type packageConf struct { + Grafana grafanaConf `json:"grafana"` +} +func getPackageJSON() (*packageConf, error) { pkgB, err := os.ReadFile("package.json") if err != nil { - return "", "", fmt.Errorf("failed to read package.json: %w", err) + return nil, fmt.Errorf("failed to read package.json: %w", err) } var pconf packageConf if err := json.Unmarshal(pkgB, &pconf); err != nil { - return "", "", fmt.Errorf("failed to decode package.json: %w", err) + return nil, fmt.Errorf("failed to decode package.json: %w", err) } - if _, err := url.ParseRequestURI(pconf.Grafana.WhatsNewURL); err != nil { + + return &pconf, nil +} + +func getReleaseURLs(semver versions.Semver, pconf *packageConf) (string, string, error) { + u := fmt.Sprintf(pconf.Grafana.WhatsNewURL, semver.Major, semver.Minor, semver.Patch) + if _, err := url.ParseRequestURI(u); err != nil { return "", "", fmt.Errorf("grafana.whatsNewUrl is invalid in package.json: %q", pconf.Grafana.WhatsNewURL) } if _, err := url.ParseRequestURI(pconf.Grafana.ReleaseNotesURL); err != nil { @@ -123,7 +138,7 @@ func getReleaseURLs() (string, string, error) { pconf.Grafana.ReleaseNotesURL) } - return pconf.Grafana.WhatsNewURL, pconf.Grafana.ReleaseNotesURL, nil + return u, pconf.Grafana.ReleaseNotesURL, nil } func Builds(baseURL *url.URL, grafana, version string, packages []packaging.BuildArtifact) ([]GCOMPackage, error) { diff --git a/pkg/build/cmd/grafanacom_test.go b/pkg/build/cmd/grafanacom_test.go index 9f4fbd7c981..1b0eb0bcf20 100644 --- a/pkg/build/cmd/grafanacom_test.go +++ b/pkg/build/cmd/grafanacom_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/grafana/grafana/pkg/build/packaging" + "github.com/grafana/grafana/pkg/build/versions" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -258,3 +259,26 @@ func TestBuildsWithPlus(t *testing.T) { }) } } + +func TestReleaseURLs(t *testing.T) { + f := "https://grafana.com/whats-new-in-v%[1]s-%[2]s" + + smv := versions.Semver{ + Major: "1", + Minor: "2", + Patch: "3", + } + + conf := packageConf{ + Grafana: grafanaConf{ + WhatsNewURL: f, + ReleaseNotesURL: "https://example.com", + }, + } + + expect := "https://grafana.com/whats-new-in-v1-2" + + a, _, err := getReleaseURLs(smv, &conf) + require.NoError(t, err) + require.Equal(t, expect, a) +} diff --git a/pkg/build/versions/parse.go b/pkg/build/versions/parse.go index 0a38af4329c..cf53f6230d4 100644 --- a/pkg/build/versions/parse.go +++ b/pkg/build/versions/parse.go @@ -1,6 +1,9 @@ package versions -import "regexp" +import ( + "regexp" + "strings" +) var semverRegex = regexp.MustCompile(`^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) @@ -13,6 +16,7 @@ type Semver struct { } func ParseSemver(version string) Semver { + version = strings.TrimPrefix(version, "v") matches := semverRegex.FindStringSubmatch(version) results := make(map[string]string) for i, name := range semverRegex.SubexpNames() { diff --git a/scripts/build/publish.sh b/scripts/build/publish.sh deleted file mode 100755 index 5da55e36b49..00000000000 --- a/scripts/build/publish.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# no relation to publish.go - -# shellcheck disable=SC2124 - -EXTRA_OPTS="$@" - -# Right now we hack this in into the publish script. -# Eventually we might want to keep a list of all previous releases somewhere. -_releaseNoteUrl="https://community.grafana.com/t/release-notes-v7-0-x/29381" -_whatsNewUrl="https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-0/" - -./scripts/build/release_publisher/release_publisher \ - --wn "${_whatsNewUrl}" \ - --rn "${_releaseNoteUrl}" \ - --version "${CIRCLE_TAG}" \ - --apikey "${GRAFANA_COM_API_KEY}" "${EXTRA_OPTS}" diff --git a/scripts/build/release_publisher/externalrelease.go b/scripts/build/release_publisher/externalrelease.go deleted file mode 100644 index 31c2daf15ca..00000000000 --- a/scripts/build/release_publisher/externalrelease.go +++ /dev/null @@ -1,71 +0,0 @@ -package main - -import ( - "fmt" - "io" - "net/http" - "strings" - "time" -) - -type releaseFromExternalContent struct { - getter urlGetter - rawVersion string - artifactConfigurations []buildArtifact -} - -func (re releaseFromExternalContent) prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error) { - version := re.rawVersion[1:] - beta := strings.Contains(version, "beta") - var rt releaseType - if beta { - rt = BETA - } else if nightly { - rt = NIGHTLY - } else { - rt = STABLE - } - - builds := []build{} - for _, ba := range re.artifactConfigurations { - url := ba.getURL(baseArchiveURL, version, rt) - sha256, err := re.getter.getContents(fmt.Sprintf("%s.sha256", url)) - if err != nil { - return nil, err - } - builds = append(builds, newBuild(url, ba, sha256)) - } - - r := release{ - Version: version, - ReleaseDate: time.Now().UTC(), - Stable: rt.stable(), - Beta: rt.beta(), - Nightly: rt.nightly(), - WhatsNewURL: whatsNewURL, - ReleaseNotesURL: releaseNotesURL, - Builds: builds, - } - return &r, nil -} - -type urlGetter interface { - getContents(url string) (string, error) -} - -type getHTTPContents struct{} - -func (getHTTPContents) getContents(url string) (string, error) { - response, err := http.Get(url) - if err != nil { - return "", err - } - - defer response.Body.Close() - all, err := io.ReadAll(response.Body) - if err != nil { - return "", err - } - - return string(all), nil -} diff --git a/scripts/build/release_publisher/main.go b/scripts/build/release_publisher/main.go deleted file mode 100644 index 97e70f5465f..00000000000 --- a/scripts/build/release_publisher/main.go +++ /dev/null @@ -1,80 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "os" -) - -func main() { - var version string - var whatsNewURL string - var releaseNotesURL string - var dryRun bool - var enterprise bool - var nightly bool - var apiKey string - - flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)") - flag.StringVar(&whatsNewURL, "wn", "", "What's new url (ex: --wn http://docs.grafana.org/guides/whats-new-in-v5-2/)") - flag.StringVar(&releaseNotesURL, "rn", "", "Grafana version (ex: --rn https://community.grafana.com/t/release-notes-v5-2-x/7894)") - flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)") - flag.BoolVar(&dryRun, "dry-run", false, "--dry-run") - flag.BoolVar(&enterprise, "enterprise", false, "--enterprise") - flag.BoolVar(&nightly, "nightly", false, "--nightly (default: false)") - flag.Parse() - - if len(os.Args) == 1 { - fmt.Println("Usage: go run publisher.go main.go --version --wn --rn --apikey --dry-run false --enterprise false --nightly false") - fmt.Println("example: go run publisher.go main.go --version v5.2.0-beta2 --wn http://docs.grafana.org/guides/whats-new-in-v5-2/ --rn https://community.grafana.com/t/release-notes-v5-2-x/7894 --apikey ASDF123 --dry-run --enterprise") - os.Exit(1) - } - - if dryRun { - log.Println("Dry-run has been enabled.") - } - var baseURL string - var builder releaseBuilder - var product string - - archiveProviderRoot := "https://dl.grafana.com" - buildArtifacts := completeBuildArtifactConfigurations - - if enterprise { - product = "grafana-enterprise" - baseURL = createBaseURL(archiveProviderRoot, "enterprise", product, nightly) - } else { - product = "grafana" - baseURL = createBaseURL(archiveProviderRoot, "oss", product, nightly) - } - - builder = releaseFromExternalContent{ - getter: getHTTPContents{}, - rawVersion: version, - artifactConfigurations: buildArtifacts, - } - - p := publisher{ - apiKey: apiKey, - apiURI: "https://grafana.com/api", - product: product, - dryRun: dryRun, - enterprise: enterprise, - baseArchiveURL: baseURL, - builder: builder, - } - if err := p.doRelease(whatsNewURL, releaseNotesURL, nightly); err != nil { - log.Fatalf("error: %v", err) - } -} -func createBaseURL(root string, bucketName string, product string, nightly bool) string { - var subPath string - if nightly { - subPath = "main" - } else { - subPath = "release" - } - - return fmt.Sprintf("%s/%s/%s/%s", root, bucketName, subPath, product) -} diff --git a/scripts/build/release_publisher/publisher.go b/scripts/build/release_publisher/publisher.go deleted file mode 100644 index 3ad3b5ba413..00000000000 --- a/scripts/build/release_publisher/publisher.go +++ /dev/null @@ -1,312 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "log" - "net/http" - "strings" - "time" -) - -type publisher struct { - apiKey string - apiURI string - product string - dryRun bool - enterprise bool - baseArchiveURL string - builder releaseBuilder -} - -type releaseBuilder interface { - prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error) -} - -func (p *publisher) doRelease(whatsNewURL string, releaseNotesURL string, nightly bool) error { - currentRelease, err := p.builder.prepareRelease(p.baseArchiveURL, whatsNewURL, releaseNotesURL, nightly) - if err != nil { - return err - } - - if err := p.postRelease(currentRelease); err != nil { - return err - } - - return nil -} - -func (p *publisher) postRelease(r *release) error { - err := p.postRequest("/versions", r, fmt.Sprintf("Create Release %s", r.Version)) - if err != nil { - return err - } - err = p.postRequest("/versions/"+r.Version, r, fmt.Sprintf("Update Release %s", r.Version)) - if err != nil { - return err - } - for _, b := range r.Builds { - err = p.postRequest(fmt.Sprintf("/versions/%s/packages", r.Version), b, fmt.Sprintf("Create Build %s %s", b.Os, b.Arch)) - if err != nil { - return err - } - err = p.postRequest(fmt.Sprintf("/versions/%s/packages/%s/%s", r.Version, b.Arch, b.Os), b, fmt.Sprintf("Update Build %s %s", b.Os, b.Arch)) - if err != nil { - return err - } - } - - return nil -} - -type releaseType int - -const ( - // STABLE is a release type constant - STABLE releaseType = iota + 1 - // BETA is a release type constant - BETA - // NIGHTLY is a release type constant - NIGHTLY -) - -func (rt releaseType) beta() bool { - return rt == BETA -} - -func (rt releaseType) stable() bool { - return rt == STABLE -} - -func (rt releaseType) nightly() bool { - return rt == NIGHTLY -} - -type buildArtifact struct { - os string - arch string - urlPostfix string - packagePostfix string -} - -func (t buildArtifact) getURL(baseArchiveURL, version string, releaseType releaseType) string { - prefix := "-" - rev := "" - - if t.os == "deb" { - prefix = "_" - } - - if t.os == "rhel" { - rev = "-1" - } - - verComponents := strings.Split(version, "-") - if len(verComponents) > 2 { - panic(fmt.Sprintf("Version string contains more than one hyphen: %q", version)) - } - - switch t.os { - case "deb", "rhel": - if len(verComponents) > 1 { - // With Debian and RPM packages, it's customary to prefix any pre-release component with a ~, since this - // is considered of lower lexical value than the empty character, and this way pre-release versions are - // considered to be of a lower version than the final version (which lacks this suffix). - version = fmt.Sprintf("%s~%s", verComponents[0], verComponents[1]) - } - } - - url := fmt.Sprintf("%s%s%s%s%s%s", baseArchiveURL, t.packagePostfix, prefix, version, rev, t.urlPostfix) - return url -} - -var completeBuildArtifactConfigurations = []buildArtifact{ - { - os: "deb", - arch: "arm64", - urlPostfix: "_arm64.deb", - }, - { - os: "rhel", - arch: "arm64", - urlPostfix: ".aarch64.rpm", - }, - { - os: "linux", - arch: "arm64", - urlPostfix: ".linux-arm64.tar.gz", - }, - { - os: "deb", - arch: "armv7", - urlPostfix: "_armhf.deb", - }, - { - os: "deb", - arch: "armv6", - packagePostfix: "-rpi", - urlPostfix: "_armhf.deb", - }, - { - os: "rhel", - arch: "armv7", - urlPostfix: ".armhfp.rpm", - }, - { - os: "linux", - arch: "armv6", - urlPostfix: ".linux-armv6.tar.gz", - }, - { - os: "linux", - arch: "armv7", - urlPostfix: ".linux-armv7.tar.gz", - }, - { - os: "darwin", - arch: "amd64", - urlPostfix: ".darwin-amd64.tar.gz", - }, - { - os: "deb", - arch: "amd64", - urlPostfix: "_amd64.deb", - }, - { - os: "rhel", - arch: "amd64", - urlPostfix: ".x86_64.rpm", - }, - { - os: "linux", - arch: "amd64", - urlPostfix: ".linux-amd64.tar.gz", - }, - { - os: "win", - arch: "amd64", - urlPostfix: ".windows-amd64.zip", - }, - { - os: "win-installer", - arch: "amd64", - urlPostfix: ".windows-amd64.msi", - }, -} - -type artifactFilter struct { - os string - arch string -} - -type filterType string - -const ( - Add filterType = "add" - Remove filterType = "remove" -) - -func filterBuildArtifacts(filterFrom []buildArtifact, ft filterType, filters []artifactFilter) ([]buildArtifact, error) { - var artifacts []buildArtifact - - for _, a := range filterFrom { - matched := false - var match buildArtifact - - for _, f := range filters { - if f.os == a.os && f.arch == a.arch { - match = a - matched = true - break - } - } - - if matched && ft == Add { - artifacts = append(artifacts, match) - } else if !matched && ft == Remove { - artifacts = append(artifacts, a) - } - } - return artifacts, nil -} - -func newBuild(url string, ba buildArtifact, sha256 string) build { - return build{ - Os: ba.os, - URL: url, - Sha256: sha256, - Arch: ba.arch, - } -} - -func (p *publisher) apiURL(url string) string { - return fmt.Sprintf("%s/%s%s", p.apiURI, p.product, url) -} - -func (p *publisher) postRequest(url string, obj any, desc string) error { - jsonBytes, err := json.Marshal(obj) - if err != nil { - return err - } - - if p.dryRun { - log.Printf("POST to %s:\n", p.apiURL(url)) - log.Println(string(jsonBytes)) - return nil - } - - req, err := http.NewRequest(http.MethodPost, p.apiURL(url), bytes.NewReader(jsonBytes)) - if err != nil { - return err - } - req.Header.Add("Authorization", "Bearer "+p.apiKey) - req.Header.Add("Content-Type", "application/json") - - res, err := http.DefaultClient.Do(req) - if err != nil { - return err - } - - if res.StatusCode == http.StatusOK { - log.Printf("Action: %s \t OK", desc) - return nil - } - - if res.Body != nil { - defer res.Body.Close() - body, err := io.ReadAll(res.Body) - if err != nil { - return err - } - - if strings.Contains(string(body), "already exists") || strings.Contains(string(body), "Nothing to update") { - log.Printf("Action: %s \t Already exists", desc) - } else { - log.Printf("Action: %s \t Failed - Status: %v", desc, res.Status) - log.Printf("Resp: %s", body) - log.Fatalf("Quitting") - } - } - - return nil -} - -type release struct { - Version string `json:"version"` - ReleaseDate time.Time `json:"releaseDate"` - Stable bool `json:"stable"` - Beta bool `json:"beta"` - Nightly bool `json:"nightly"` - WhatsNewURL string `json:"whatsNewUrl"` - ReleaseNotesURL string `json:"releaseNotesUrl"` - Builds []build `json:"-"` -} - -type build struct { - Os string `json:"os"` - URL string `json:"url"` - Sha256 string `json:"sha256"` - Arch string `json:"arch"` -} diff --git a/scripts/build/release_publisher/publisher_test.go b/scripts/build/release_publisher/publisher_test.go deleted file mode 100644 index d31d161d21a..00000000000 --- a/scripts/build/release_publisher/publisher_test.go +++ /dev/null @@ -1,201 +0,0 @@ -package main - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestPreparingReleaseFromRemote(t *testing.T) { - cases := []struct { - version string - expectedVersion string - whatsNewURL string - relNotesURL string - nightly bool - expectedBeta bool - expectedStable bool - expectedArch string - expectedOs string - expectedURL string - baseArchiveURL string - buildArtifacts []buildArtifact - }{ - { - version: "v5.2.0-beta1", - expectedVersion: "5.2.0-beta1", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: false, - expectedBeta: true, - expectedStable: false, - expectedArch: "amd64", - expectedOs: "linux", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.0-beta1.linux-amd64.tar.gz", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{{"linux", "amd64", ".linux-amd64.tar.gz", ""}}, - }, - { - version: "v5.2.3", - expectedVersion: "5.2.3", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: false, - expectedBeta: false, - expectedStable: true, - expectedArch: "amd64", - expectedOs: "rhel", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm", ""}}, - }, - { - version: "v5.4.0-pre1asdf", - expectedVersion: "5.4.0-pre1asdf", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: true, - expectedBeta: false, - expectedStable: false, - expectedArch: "amd64", - expectedOs: "rhel", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0~pre1asdf-1.x86_64.rpm", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm", ""}}, - }, - { - version: "v5.4.0-pre1asdf", - expectedVersion: "5.4.0-pre1asdf", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: true, - expectedBeta: false, - expectedStable: false, - expectedArch: "armv6", - expectedOs: "deb", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-rpi_5.4.0~pre1asdf_armhf.deb", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{ - {os: "deb", arch: "armv6", urlPostfix: "_armhf.deb", packagePostfix: "-rpi"}, - }, - }, - { - version: "v5.4.0-pre1asdf", - expectedVersion: "5.4.0-pre1asdf", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: true, - expectedBeta: false, - expectedStable: false, - expectedArch: "amd64", - expectedOs: "win-installer", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.windows-amd64.msi", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{{"win-installer", "amd64", ".windows-amd64.msi", ""}}, - }, - { - version: "v5.4.0-pre1asdf", - expectedVersion: "5.4.0-pre1asdf", - whatsNewURL: "https://whatsnews.foo/", - relNotesURL: "https://relnotes.foo/", - nightly: true, - expectedBeta: false, - expectedStable: false, - expectedArch: "amd64", - expectedOs: "win", - expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.windows-amd64.zip", - baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana", - buildArtifacts: []buildArtifact{{"win", "amd64", ".windows-amd64.zip", ""}}, - }, - } - - for _, test := range cases { - builder := releaseFromExternalContent{ - getter: mockHTTPGetter{}, - rawVersion: test.version, - artifactConfigurations: test.buildArtifacts, - } - - t.Log("Preparing release", "baseArchiveURL", test.baseArchiveURL, "nightly", test.nightly) - rel, err := builder.prepareRelease(test.baseArchiveURL, test.whatsNewURL, test.relNotesURL, test.nightly) - require.NoError(t, err) - - assert.Equal(t, test.expectedBeta, rel.Beta) - assert.Equal(t, test.expectedStable, rel.Stable) - assert.Equal(t, test.expectedVersion, rel.Version) - - assert.Len(t, rel.Builds, len(test.buildArtifacts)) - - build := rel.Builds[0] - assert.Equal(t, test.expectedArch, build.Arch) - assert.Equal(t, test.expectedOs, build.Os) - assert.Equal(t, test.expectedURL, build.URL) - } -} - -type mockHTTPGetter struct{} - -func (mockHTTPGetter) getContents(url string) (string, error) { - return url, nil -} - -func TestFilterBuildArtifacts(t *testing.T) { - buildArtifacts, _ := filterBuildArtifacts(completeBuildArtifactConfigurations, Add, []artifactFilter{ - {os: "deb", arch: "amd64"}, - {os: "rhel", arch: "amd64"}, - {os: "linux", arch: "amd64"}, - {os: "win", arch: "amd64"}, - }) - - if len(buildArtifacts) != 4 { - t.Errorf("Expected 4 build artifacts after filtering, but was %v", len(buildArtifacts)) - } - - buildArtifacts, err := filterBuildArtifacts([]buildArtifact{ - { - os: "linux", - arch: "amd64", - }, - { - os: "arm", - arch: "amd64", - }, - { - os: "darwin", - arch: "amd64", - }, - }, Remove, []artifactFilter{ - {os: "darwin", arch: "amd64"}, - }) - - if err != nil { - t.Error() - } - - if len(buildArtifacts) != 2 { - t.Errorf("Expected 2 artifacts, was %v", len(buildArtifacts)) - } - - for _, ba := range buildArtifacts { - if ba.arch == "amd64" && ba.os == "darwin" { - t.Errorf("darwin/amd64 should be gone due to filtering") - } - } - - left := []buildArtifact{ - { - os: "linux", - arch: "amd64", - }, - { - os: "arm", - arch: "amd64", - }, - } - - if !reflect.DeepEqual(left, buildArtifacts) { - t.Errorf("Lists should have been equal but was, expected=%v, actual=%v", left, buildArtifacts) - } -} diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz.sha256 b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz.sha256 deleted file mode 100644 index c3068040269..00000000000 --- a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz.sha256 +++ /dev/null @@ -1 +0,0 @@ -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi.sha256 b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi.sha256 deleted file mode 100644 index c3068040269..00000000000 --- a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi.sha256 +++ /dev/null @@ -1 +0,0 @@ -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip.sha256 b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip.sha256 deleted file mode 100644 index c3068040269..00000000000 --- a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip.sha256 +++ /dev/null @@ -1 +0,0 @@ -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm.sha256 b/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm.sha256 deleted file mode 100644 index c3068040269..00000000000 --- a/scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm.sha256 +++ /dev/null @@ -1 +0,0 @@ -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb b/scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb.sha256 b/scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb.sha256 deleted file mode 100644 index c3068040269..00000000000 --- a/scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb.sha256 +++ /dev/null @@ -1 +0,0 @@ -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/scripts/drone/pipelines/whats_new_checker.star b/scripts/drone/pipelines/whats_new_checker.star deleted file mode 100644 index 2c56be573ce..00000000000 --- a/scripts/drone/pipelines/whats_new_checker.star +++ /dev/null @@ -1,42 +0,0 @@ -""" -This module contains logic for checking if the package.json whats new url matches with the in-flight tag. -""" - -load( - "scripts/drone/steps/lib.star", - "compile_build_cmd", -) -load( - "scripts/drone/utils/images.star", - "images", -) -load( - "scripts/drone/utils/utils.star", - "pipeline", -) - -def whats_new_checker_step(): - return { - "name": "whats-new-checker", - "image": images["go"], - "depends_on": [ - "compile-build-cmd", - ], - "commands": [ - "./bin/build whatsnew-checker", - ], - } - -def whats_new_checker_pipeline(trigger): - environment = {"EDITION": "oss"} - steps = [ - compile_build_cmd(), - whats_new_checker_step(), - ] - return pipeline( - name = "release-whatsnew-checker", - trigger = trigger, - services = [], - steps = steps, - environment = environment, - ) diff --git a/scripts/drone/rgm.star b/scripts/drone/rgm.star index 61694556c37..f81effc892a 100644 --- a/scripts/drone/rgm.star +++ b/scripts/drone/rgm.star @@ -16,10 +16,6 @@ load( "scripts/drone/pipelines/test_frontend.star", "test_frontend", ) -load( - "scripts/drone/pipelines/whats_new_checker.star", - "whats_new_checker_pipeline", -) load( "scripts/drone/steps/github.star", "github_app_generate_token_step", @@ -291,7 +287,6 @@ def rgm_tag_pipeline(): return [ build, - whats_new_checker_pipeline(tag_trigger), verify_release_pipeline( trigger = tag_trigger, name = "rgm-tag-verify-prerelease-assets",