Commit c9a4da42 by Leonard Gram

build: publisher handles nightly builds.

parent 26cbc6be
...@@ -14,7 +14,7 @@ type releaseFromExternalContent struct { ...@@ -14,7 +14,7 @@ type releaseFromExternalContent struct {
artifactConfigurations []buildArtifact 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:] version := re.rawVersion[1:]
isBeta := strings.Contains(version, "beta") isBeta := strings.Contains(version, "beta")
...@@ -30,9 +30,9 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl ...@@ -30,9 +30,9 @@ func (re releaseFromExternalContent) prepareRelease(baseArchiveUrl, whatsNewUrl
r := release{ r := release{
Version: version, Version: version,
ReleaseDate: time.Now().UTC(), ReleaseDate: time.Now().UTC(),
Stable: !isBeta, Stable: !isBeta && !nightly,
Beta: isBeta, Beta: isBeta,
Nightly: false, Nightly: nightly,
WhatsNewUrl: whatsNewUrl, WhatsNewUrl: whatsNewUrl,
ReleaseNotesUrl: releaseNotesUrl, ReleaseNotesUrl: releaseNotesUrl,
Builds: builds, Builds: builds,
......
...@@ -17,7 +17,7 @@ type releaseLocalSources struct { ...@@ -17,7 +17,7 @@ type releaseLocalSources struct {
artifactConfigurations []buildArtifact 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) buildData := r.findBuilds(baseArchiveUrl)
rel := release{ rel := release{
...@@ -25,7 +25,7 @@ func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string, ...@@ -25,7 +25,7 @@ func (r releaseLocalSources) prepareRelease(baseArchiveUrl, whatsNewUrl string,
ReleaseDate: time.Now().UTC(), ReleaseDate: time.Now().UTC(),
Stable: false, Stable: false,
Beta: false, Beta: false,
Nightly: true, Nightly: nightly,
WhatsNewUrl: whatsNewUrl, WhatsNewUrl: whatsNewUrl,
ReleaseNotesUrl: releaseNotesUrl, ReleaseNotesUrl: releaseNotesUrl,
Builds: buildData.builds, Builds: buildData.builds,
......
...@@ -14,6 +14,7 @@ func main() { ...@@ -14,6 +14,7 @@ func main() {
var dryRun bool var dryRun bool
var enterprise bool var enterprise bool
var fromLocal bool var fromLocal bool
var nightly bool
var apiKey string var apiKey string
flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)") flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)")
...@@ -22,11 +23,13 @@ func main() { ...@@ -22,11 +23,13 @@ func main() {
flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)") flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)")
flag.BoolVar(&dryRun, "dry-run", false, "--dry-run") flag.BoolVar(&dryRun, "dry-run", false, "--dry-run")
flag.BoolVar(&enterprise, "enterprise", false, "--enterprise") 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() flag.Parse()
nightly = fromLocal
if len(os.Args) == 1 { 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") 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) os.Exit(1)
} }
...@@ -52,12 +55,14 @@ func main() { ...@@ -52,12 +55,14 @@ func main() {
} }
} }
archiveProviderRoot := "https://s3-us-west-2.amazonaws.com"
if enterprise { if enterprise {
baseUrl = "https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/release/grafana-enterprise"
product = "grafana-enterprise" product = "grafana-enterprise"
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-enterprise-releases", product, nightly)
} else { } else {
baseUrl = "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana"
product = "grafana" product = "grafana"
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-releases", product, nightly)
} }
p := publisher{ p := publisher{
...@@ -69,7 +74,17 @@ func main() { ...@@ -69,7 +74,17 @@ func main() {
baseArchiveUrl: baseUrl, baseArchiveUrl: baseUrl,
builder: builder, builder: builder,
} }
if err := p.doRelease(whatsNewUrl, releaseNotesUrl); err != nil { if err := p.doRelease(whatsNewUrl, releaseNotesUrl, nightly); err != nil {
log.Fatalf("error: %v", err) 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 { ...@@ -22,11 +22,11 @@ type publisher struct {
} }
type releaseBuilder interface { 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 { func (p *publisher) doRelease(whatsNewUrl string, releaseNotesUrl string, nightly bool) error {
currentRelease, err := p.builder.prepareRelease(p.baseArchiveUrl, whatsNewUrl, releaseNotesUrl) currentRelease, err := p.builder.prepareRelease(p.baseArchiveUrl, whatsNewUrl, releaseNotesUrl, nightly)
if err != nil { if err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment