release

package
v0.0.0-...-1660908 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

README

release

The release command is a parent command for running the release process. release consists of three subcommands, which represent the three phases of the release flow:

prepare

Used to prepare Gutenberg and Gutenberg Mobile PRs for the release. Contains three subcommands:

  • all: Prepare both Gutenberg and Gutenberg Mobile PRs release
  • gb: Prepare Gutenberg PR for a mobile release
  • gbm: Prepare Gutenberg Mobile PR release

Usage

Prepare a release for both platforms:

go run main.go release prepare all v1.107.0

Prepare a release for Gutenberg only:

go run main.go release prepare gb v1.107.0

Prepare a release for Gutenberg Mobile only:

go run main.go release prepare gbm v1.107.0

Flags:

  • --k, --keep: Keep temporary directory after running command
  • --no-tag: Prevent tagging the release
  • -h, --help: Command line help for prepare
integrate

Used to integrate a release into the main apps WordPress-iOS and WordPress-Android. If the Android or iOS flags are set, only that platform will be integrated. Otherwise, both will be integrated.

Usage

After the prepare command has been run and the CI has finished, the main apps integration PRs can be created:

go run main.go release integrate v1.107.0

Flags

  • -a, --android: Only integrate Android
  • -i, --ios: Only integrate iOS
  • -h, --help: Command line help for integrate command
status

Command used to check the status of any given release:

Usage

go run main.go release status 1.07.0 

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntegrateCmd = &cobra.Command{
	Use:   "integrate",
	Short: "integrate a release",
	Long:  `Use this command to integrate a release. If the Android or iOS flags are set, only that platform will be integrated. Otherwise, both will be integrated.`,
	Run: func(cmd *cobra.Command, args []string) {
		semver, err := utils.GetVersionArg(args)
		exitIfError(err, 1)
		version := semver.String()

		gbmPr, err := release.FindGbmReleasePr(version)
		exitIfError(err, 1)
		if gbmPr.Number == 0 {
			exitIfError(errors.New("no GBM PR found"), 1)
		}

		ri := integrate.ReleaseIntegration{
			Version:    version,
			BaseBranch: "trunk",
			HeadBranch: fmt.Sprintf("gutenberg/integrate_release_%s", version),
			GbmPr:      gbmPr,
		}

		results := []gh.PullRequest{}

		createAndroidPr := func() {
			androidDir := filepath.Join(tempDir, "android")
			err := os.MkdirAll(androidDir, os.ModePerm)
			exitIfError(err, 1)
			androidRi := ri
			target := integrate.AndroidIntegration{}
			androidRi.Target = target
			pr, err := androidRi.Run(filepath.Join(tempDir, "android"))
			if err != nil {
				console.Warn(err.Error())
			}
			results = append(results, pr)
		}

		createIosPr := func() {
			iosDir := filepath.Join(tempDir, "ios")
			err := os.MkdirAll(iosDir, os.ModePerm)
			exitIfError(err, 1)

			iosRi := ri
			target := integrate.IosIntegration{}
			iosRi.Target = target
			pr, err := iosRi.Run(filepath.Join(tempDir, "ios"))
			if err != nil {
				console.Warn(err.Error())
			}
			results = append(results, pr)
		}

		both = !android && !ios || ios && android

		switch {
		case both:
			console.Info("Integrating GBM version %s into both iOS and Android", version)
			createAndroidPr()
			createIosPr()

		case android:
			console.Info("Integrating GBM version %s into Android", version)
			createAndroidPr()

		case ios:
			console.Info("Integrating GBM version %s into iOS", version)
			createIosPr()
		}

		if len(results) == 0 {
			exitIfError(errors.New("no PRs were created"), 1)
		}
		for _, pr := range results {
			if pr.Number != 0 {
				console.Info("Created PR %s", pr.Url)
			}
		}
	},
}
View Source
var ReleaseCmd = &cobra.Command{
	Use:   "release",
	Short: "Release Gutenberg Mobile",
}
View Source
var StatusCmd = &cobra.Command{
	Use:   "status",
	Short: "get the status of a release",
	Long:  `Use this command to get the status of a release.`,
	Run: func(cmd *cobra.Command, args []string) {
		semver, err := utils.GetVersionArg(args)
		exitIfError(err, 1)

		version := semver.String()

		heading := console.Heading
		headingRow := console.HeadingRow
		row := console.Row
		basic := color.New(color.FgWhite)

		console.Print(heading, "\nRelease %s Status\n", version)

		rel, err := release.GetGbmRelease(version)
		exitIfError(err, 1)

		if (rel != gh.Release{}) {
			console.Print(heading, "\n🎉 Release %s has been published!\n %s\n", version, rel.Url)
		}

		prs := []gh.PullRequest{}
		gbPr, gbmPr, androidPr, iosPr := gh.PullRequest{}, gh.PullRequest{}, gh.PullRequest{}, gh.PullRequest{}

		gbPr, err = release.FindGbReleasePr(version)
		if err != nil {
			console.Warn("Could not get Gutenberg PR: %s", err)
		}
		gbPr.Repo = repo.GetOrg("gutenberg") + "/gutenberg"
		prs = append(prs, gbPr)

		gbmPr, err = release.FindGbmReleasePr(version)
		if err != nil {
			console.Warn("Could not get Gutenberg Mobile PR: %s", err)
		}
		gbmPr.Repo = repo.GetOrg("gutenberg-mobile") + "/gutenberg-mobile"
		prs = append(prs, gbmPr)

		androidPr, err = release.FindAndroidReleasePr(version)
		if err != nil {
			console.Warn("Could not find Android PR: %s", err)
		}
		androidPr.Repo = repo.GetOrg("WordPress-Android") + "/WordPress-Android"
		prs = append(prs, androidPr)

		iosPr, err = release.FindIosReleasePr(version)
		if err != nil {
			console.Warn("Could not find iOS PR: %s", err)
		}
		iosPr.Repo = repo.GetOrg("WordPress-iOS") + "/WordPress-iOS"
		prs = append(prs, iosPr)

		console.Print(heading, "Release Prs:")
		console.Print(headingRow, "%-36s %-10s %-10v %s", "Repo", "State", "Mergeable", "Url")

		for _, pr := range prs {
			if pr.Number == 0 {
				pr.State = "…"
				pr.Url = "…"
			}
			console.Print(row, "• %-34s %-10s %-10v %s", pr.Repo, pr.State, pr.Mergeable, pr.Url)
		}

		console.Print(heading, "\nGutenberg Mobile Build Status\n")
		if gbmPr.Number == 0 {
			console.Print(row, "...Waiting for Gutenberg Mobile PR to be created before checking build status")
			return
		}
		sha := gbmPr.Head.Sha
		console.Print(basic, "Getting Gutenberg Builds for sha: %s", sha)

		console.Print(headingRow, "%-10s %-10s", "Platform", "Status")

		androidReady, err := gbm.AndroidGbmBuildPublished(gbmPr)
		if err != nil {
			console.Warn("Could not get Android build status: %s", err)
		}

		iosReady, err := gbm.IosGbmBuildPublished(gbmPr)

		if err != nil {
			console.Warn("Could not get iOS build status: %s", err)
		}
		console.Print(row, "%-10s %-10v", "Android", androidReady)
		console.Print(row, "%-10s %-10v", "iOS", iosReady)

	},
}

Functions

func Execute

func Execute()

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL