Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Add ability to self update binary #247

Merged
merged 4 commits into from
Mar 12, 2024
Merged

[CLI] Add ability to self update binary #247

merged 4 commits into from
Mar 12, 2024

Conversation

jhnstn
Copy link
Member

@jhnstn jhnstn commented Mar 8, 2024

This adds the ability to self update the cli tool.

Why?

Apple requires code signing for all binaries, making it tricky to download the gbm-cli tool directly from the github releases pages. This change will make it easy for release wranglers to update the tool.

Testing

  • Change the version in ./gbm-cli/cmd/root.go to a lower version (current is 1.5.0), example patch:
diff --git a/gbm-cli/cmd/root.go b/gbm-cli/cmd/root.go
index e921336..a7fefb9 100644
--- a/gbm-cli/cmd/root.go
+++ b/gbm-cli/cmd/root.go
@@ -8,7 +8,7 @@ import (
 	"github.com/wordpress-mobile/release-toolkit-gutenberg-mobile/gbm-cli/pkg/console"
 )
 
-const Version = "v1.5.0"
+const Version = "v1.4.0"
 
 // rootCmd represents the base command when called without any subcommands
 var rootCmd = &cobra.Command{
  • Run go build -o ./bin/gbm-cli
  • Run ./bin/gbm-cli --version
  • Cancel the option to update and note the version number. It should be the value added in the first step
  • Run ./bin/gbm-cli --version again
  • Accept the offer to update
  • Note that the version message shows the latest version in Github
  • Run ./bin/gbm-cli --version again
  • Note that there is no prompt to update

@@ -39,7 +40,7 @@ var StatusCmd = &cobra.Command{
// Check to see if the release has been published
rel, _ := release.GetGbmRelease(version)

if (rel != gh.Release{}) {
if (!reflect.DeepEqual(rel, gh.Release{})) {
Copy link
Member Author

@jhnstn jhnstn Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only possible regression since the simple equality won't work with the array of ReleaseAsset added to the Release struct. This can be verified by running a status check on a published release e.g.

go run main.go release status 1.114.1

@jhnstn jhnstn merged commit 77eed4a into trunk Mar 12, 2024
2 checks passed
@jhnstn jhnstn deleted the add/self-update branch March 12, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant