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.
This commit is contained in:
Kevin Minehart
2025-02-20 12:00:15 -06:00
committed by GitHub
parent e54149e551
commit 49e5f77dd1
21 changed files with 59 additions and 483 deletions

View File

@ -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}"

View File

@ -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
}

View File

@ -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 <v> --wn <what's new url> --rn <release notes url> --apikey <api key> --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)
}

View File

@ -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)
}
}

View File

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View File

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View File

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View File

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View File

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View File

@ -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,
)

View File

@ -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",