Finish pushing tag

This commit is contained in:
Donny Xia
2020-05-18 14:30:05 -07:00
parent 650f111e63
commit 557cd656ab

View File

@@ -163,13 +163,13 @@ var release = &cobra.Command{
} else if !noDryRun {
logInfo("Skipping push module %s. Run with --no-dry-run to push the release.", mod.name)
} else {
// TODO: Push tags
pushRelease(tempDir, branch, mod)
}
// Clean
cleanGit()
pruneWorktree(pwd)
deleteBranch(pwd, branch)
logInfo("Done")
logInfo("Module %s completes", mod.name)
},
}
@@ -442,3 +442,33 @@ func merge(path, branch string) {
}
logInfo("Finished merging")
}
func pushRelease(path, branch string, mod module) {
logInfo("Pushing branch %s", branch)
cmd := exec.Command("git", "push", "upstream", branch)
cmd.Dir = path
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
logFatal(string(stdoutStderr))
}
logInfo("Creating tag %s", mod.Tag())
cmd = exec.Command(
"git", "tag",
"-a", mod.Tag(),
"-m", fmt.Sprintf("Release %s on branch %s", mod.Tag(), branch),
)
cmd.Dir = path
stdoutStderr, err = cmd.CombinedOutput()
if err != nil {
logFatal(string(stdoutStderr))
}
logInfo("Pushing tag %s", mod.Tag())
cmd = exec.Command("git", "push", "upstream", mod.Tag())
cmd.Dir = path
stdoutStderr, err = cmd.CombinedOutput()
if err != nil {
logFatal(string(stdoutStderr))
}
}