mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
See, $ gometalinter --vendor --disable-all --enable=golint ./... build/release_publisher/externalrelease.go:55:6⚠️ type getHttpContents should be getHTTPContents (golint) build/release_publisher/publisher.go:18:2⚠️ struct field apiUri should be apiURI (golint) build/release_publisher/publisher.go:66:6⚠️ exported type ReleaseType should have comment or be unexported (golint) build/release_publisher/publisher.go:69:2⚠️ exported const STABLE should have comment (or a comment on this block) or be unexported (golint) build/release_publisher/publisher.go:185:16⚠️ should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (golint) build/release_publisher/publisher_test.go:102:6⚠️ type mockHttpGetter should be mockHTTPGetter (golint)
104 lines
3.0 KiB
Go
104 lines
3.0 KiB
Go
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 fromLocal 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(&fromLocal, "from-local", false, "--from-local (builds will be tagged as nightly)")
|
|
flag.Parse()
|
|
|
|
nightly = fromLocal
|
|
|
|
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)
|
|
var err error
|
|
buildArtifacts, err = filterBuildArtifacts([]artifactFilter{
|
|
{os: "deb", arch: "amd64"},
|
|
{os: "rhel", arch: "amd64"},
|
|
{os: "linux", arch: "amd64"},
|
|
{os: "win", arch: "amd64"},
|
|
})
|
|
|
|
if err != nil {
|
|
log.Fatalf("Could not filter to the selected build artifacts, err=%v", err)
|
|
}
|
|
|
|
} else {
|
|
product = "grafana"
|
|
baseURL = createBaseURL(archiveProviderRoot, "oss", product, nightly)
|
|
}
|
|
|
|
if fromLocal {
|
|
path, _ := os.Getwd()
|
|
builder = releaseLocalSources{
|
|
path: path,
|
|
artifactConfigurations: buildArtifacts,
|
|
}
|
|
} else {
|
|
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 = "master"
|
|
} else {
|
|
subPath = "release"
|
|
}
|
|
|
|
return fmt.Sprintf("%s/%s/%s/%s", root, bucketName, subPath, product)
|
|
}
|