This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package updater | ||
|
||
import ( | ||
"github.com/pieterclaerhout/go-james/internal" | ||
"github.com/pieterclaerhout/go-james/internal/updater" | ||
"github.com/pieterclaerhout/go-james/versioninfo" | ||
"github.com/tucnak/climax" | ||
) | ||
|
||
// UpdateCmd defines the update command | ||
var UpdateCmd = climax.Command{ | ||
Name: "update", | ||
Brief: "Updates " + versioninfo.ProjectName + " to the latest available release", | ||
Help: "Updates " + versioninfo.ProjectName + " to the latest available release", | ||
Handle: func(ctx climax.Context) int { | ||
|
||
tool := updater.Updater{} | ||
|
||
executor := internal.NewExecutor("") | ||
return executor.RunTool(tool, false) | ||
|
||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package updater | ||
|
||
import ( | ||
"github.com/blang/semver" | ||
"github.com/pieterclaerhout/go-james/internal/common" | ||
"github.com/pieterclaerhout/go-james/internal/config" | ||
"github.com/pieterclaerhout/go-james/versioninfo" | ||
"github.com/rhysd/go-github-selfupdate/selfupdate" | ||
) | ||
|
||
const repoName = "pieterclaerhout/go-james" | ||
|
||
// Updater implements the "updater" command | ||
type Updater struct { | ||
common.Logging | ||
} | ||
|
||
// Execute executes the command | ||
func (updater Updater) Execute(project common.Project, cfg config.Config) error { | ||
|
||
v := semver.MustParse(versioninfo.Version) | ||
|
||
latest, err := selfupdate.UpdateSelf(v, repoName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if latest.Version.Equals(v) { | ||
updater.LogInfo("Current binary is the latest version", versioninfo.Version) | ||
} else { | ||
updater.LogInfo("Successfully updated to version", latest.Version) | ||
updater.LogInfo("Release note:\n", latest.ReleaseNotes) | ||
} | ||
|
||
return nil | ||
|
||
} | ||
|
||
// RequiresBuild indicates if a build is required before running the command | ||
func (updater Updater) RequiresBuild() bool { | ||
return false | ||
} |