mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
build: publisher handles nightly builds.
This commit is contained in:
@@ -14,7 +14,7 @@ type releaseFromExternalContent struct {
|
||||
artifactConfigurations []buildArtifact
|
||||
}
|
||||
|
||||
func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string) (*release, error) {
|
||||
func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) {
|
||||
version := re.rawVersion[1:]
|
||||
isBeta := strings.Contains(version, "beta")
|
||||
|
||||
@@ -30,9 +30,9 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
|
||||
r := release{
|
||||
Version: version,
|
||||
ReleaseDate: time.Now().UTC(),
|
||||
Stable: !isBeta,
|
||||
Stable: !isBeta && !nightly,
|
||||
Beta: isBeta,
|
||||
Nightly: false,
|
||||
Nightly: nightly,
|
||||
WhatsNewUrl: whatsNewUrl,
|
||||
ReleaseNotesUrl: releaseNotesUrl,
|
||||
Builds: builds,
|
||||
|
||||
@@ -17,7 +17,7 @@ type releaseLocalSources struct {
|
||||
artifactConfigurations []buildArtifact
|
||||
}
|
||||
|
||||
func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string) (*release, error) {
|
||||
func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error) {
|
||||
buildData := r.findBuilds(baseArchiveUrl)
|
||||
|
||||
rel := release{
|
||||
@@ -25,7 +25,7 @@ func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string,
|
||||
ReleaseDate: time.Now().UTC(),
|
||||
Stable: false,
|
||||
Beta: false,
|
||||
Nightly: true,
|
||||
Nightly: nightly,
|
||||
WhatsNewUrl: whatsNewUrl,
|
||||
ReleaseNotesUrl: releaseNotesUrl,
|
||||
Builds: buildData.builds,
|
||||
|
||||
@@ -14,6 +14,7 @@ func main() {
|
||||
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)")
|
||||
@@ -22,11 +23,13 @@ func main() {
|
||||
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")
|
||||
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")
|
||||
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)
|
||||
}
|
||||
@@ -52,12 +55,14 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
archiveProviderRoot := "https://s3-us-west-2.amazonaws.com"
|
||||
|
||||
if enterprise {
|
||||
baseUrl = "https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/release/grafana-enterprise"
|
||||
product = "grafana-enterprise"
|
||||
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-enterprise-releases", product, nightly)
|
||||
} else {
|
||||
baseUrl = "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana"
|
||||
product = "grafana"
|
||||
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-releases", product, nightly)
|
||||
}
|
||||
|
||||
p := publisher{
|
||||
@@ -69,7 +74,17 @@ func main() {
|
||||
baseArchiveUrl: baseUrl,
|
||||
builder: builder,
|
||||
}
|
||||
if err := p.doRelease(whatsNewUrl, releaseNotesUrl); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ type publisher struct {
|
||||
}
|
||||
|
||||
type releaseBuilder interface {
|
||||
prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string) (*release, error)
|
||||
prepareRelease(baseArchiveUrl, whatsNewUrl string, releaseNotesUrl string, nightly bool) (*release, error)
|
||||
}
|
||||
|
||||
func (p *publisher) doRelease(whatsNewUrl string, releaseNotesUrl string) error {
|
||||
currentRelease, err := p.builder.prepareRelease(p.baseArchiveUrl, whatsNewUrl, releaseNotesUrl)
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user