Skip to content

Commit

Permalink
Fix wrongfully publishing nightly versions as beta
Browse files Browse the repository at this point in the history
  • Loading branch information
guicaulada committed Oct 16, 2023
1 parent a2e0acf commit 7e31343
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
8 changes: 8 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ var GCOMFlags = []cli.Flag{
Usage: "URL used to download packages from grafana.com",
Required: true,
},
&cli.BoolFlag{
Name: "beta",
Usage: "Use when publishing a beta version",
},
&cli.BoolFlag{
Name: "nightly",
Usage: "Use when publishing a nightly version",
},
}

// JoinFlags combines several slices of flags into one slice of flags.
Expand Down
4 changes: 4 additions & 0 deletions containers/opts_gcom.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type GCOMOpts struct {
URL *url.URL
DownloadURL *url.URL
ApiKey string
Beta bool
Nightly bool
}

func GCOMOptsFromFlags(c cliutil.CLIContext) (*GCOMOpts, error) {
Expand All @@ -26,5 +28,7 @@ func GCOMOptsFromFlags(c cliutil.CLIContext) (*GCOMOpts, error) {
URL: apiUrl,
DownloadURL: downloadUrl,
ApiKey: c.String("api-key"),
Beta: c.Bool("beta"),
Nightly: c.Bool("nightly"),
}, nil
}
14 changes: 7 additions & 7 deletions pipelines/gcom_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ import (
"golang.org/x/sync/semaphore"
)

func VersionPayloadFromFileName(name string) *containers.GCOMVersionPayload {
func VersionPayloadFromFileName(name string, opts *containers.GCOMOpts) *containers.GCOMVersionPayload {
var (
opts = TarOptsFromFileName(name)
splitVersion = strings.Split(opts.Version, ".")
tarOpts = TarOptsFromFileName(name)
splitVersion = strings.Split(tarOpts.Version, ".")
stable = true
nightly = false
beta = false
)

if strings.Contains(opts.Version, "-") {
if opts.Beta {
stable = false
beta = true
}
if strings.Contains(opts.Version, "nightly") {
if opts.Nightly {
beta = false
nightly = true
}

return &containers.GCOMVersionPayload{
Version: opts.Version,
Version: tarOpts.Version,
ReleaseDate: time.Now().Format(time.RFC3339Nano),
Stable: stable,
Beta: beta,
Expand Down Expand Up @@ -95,7 +95,7 @@ func PublishGCOM(ctx context.Context, d *dagger.Client, args PipelineArgs) error
tarOpts := TarOptsFromFileName(name)
if _, ok := versionPayloads[tarOpts.Version]; !ok {
log.Printf("[%s] Building version payload", tarOpts.Version)
versionPayloads[tarOpts.Version] = VersionPayloadFromFileName(name)
versionPayloads[tarOpts.Version] = VersionPayloadFromFileName(name, opts)
}
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/drone_publish_nightly_enterprise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dagger run --silent go run ./cmd gcom publish \
$(find $local_dir | grep -e .rpm -e .tar.gz -e .exe -e .zip -e .deb | grep -v sha256 | awk '{print "--package=file://"$0}') \
--api-key=${GCOM_API_KEY} \
--api-url="https://grafana-dev.com/api/grafana-enterprise" \
--download-url="https://dl.grafana.com/enterprise/release"
--download-url="https://dl.grafana.com/enterprise/release" \
--nightly
3 changes: 2 additions & 1 deletion scripts/drone_publish_nightly_grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dagger run --silent go run ./cmd gcom publish \
$(find $local_dir | grep -e .rpm -e .tar.gz -e .exe -e .zip -e .deb | grep -v sha256 | awk '{print "--package=file://"$0}') \
--api-key=${GCOM_API_KEY} \
--api-url="https://grafana.com/api/grafana" \
--download-url="https://dl.grafana.com/oss/release"
--download-url="https://dl.grafana.com/oss/release" \
--nightly

0 comments on commit 7e31343

Please sign in to comment.