CI: Backport CI/Release related code to v9.3.x (#62752)
* Batch-move everything
* go mod tidy
* make drone
* Remove genversions
* Bump alpine image
* Revert back pkg/build/docker/build.go
* Make sure correct enterprise branch is checked out
* Add enterprise2 version
* Remove extensions
* Bump build container
* backport node 18 test fix
(cherry picked from commit 4ff03fdbfb)
* Update scripts/drone
* Add more commands
* Fix starlark link
* Copy .drone.star
* Add drone target branch for custom events
---------
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/grafana/grafana/pkg/build/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@@ -39,9 +40,9 @@ var (
|
||||
errReleaseNotFound = errors.New(`release not found, use "--create" to create the release`)
|
||||
)
|
||||
|
||||
func PublishGitHub(ctx *cli.Context) error {
|
||||
func PublishGithub(ctx *cli.Context) error {
|
||||
token := os.Getenv("GH_TOKEN")
|
||||
f, err := getFlags(ctx)
|
||||
f, err := getPublishGithubFlags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -55,7 +56,7 @@ func PublishGitHub(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
if f.dryRun {
|
||||
return runDryRun(f, token, ctx)
|
||||
return runPublishGithubDryRun(f, token, ctx)
|
||||
}
|
||||
|
||||
client := newGithubClient(ctx.Context, token)
|
||||
@@ -99,8 +100,8 @@ func githubRepositoryClient(ctx context.Context, token string) githubRepositoryS
|
||||
return client.Repositories
|
||||
}
|
||||
|
||||
func getFlags(ctx *cli.Context) (*publishGithubFlags, error) {
|
||||
metadata, err := GenerateMetadata(ctx)
|
||||
func getPublishGithubFlags(ctx *cli.Context) (*publishGithubFlags, error) {
|
||||
metadata, err := config.GenerateMetadata(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -130,12 +131,12 @@ func getFlags(ctx *cli.Context) (*publishGithubFlags, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func runDryRun(f *publishGithubFlags, token string, ctx *cli.Context) error {
|
||||
func runPublishGithubDryRun(f *publishGithubFlags, token string, ctx *cli.Context) error {
|
||||
client := newGithubClient(ctx.Context, token)
|
||||
fmt.Println("Dry-Run: Retrieving release on repository by tag")
|
||||
release, res, err := client.GetReleaseByTag(ctx.Context, f.repo.owner, f.repo.name, f.tag)
|
||||
if err != nil && res.StatusCode != 404 {
|
||||
fmt.Println("Dry-Run: GitHub communication error:\n", err)
|
||||
fmt.Println("Dry-Run: Github communication error:\n", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user