summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-10 21:33:49 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-10 21:34:17 +1000
commitd08241b2ea2f6cbf030be31c116502c92e55b1c7 (patch)
tree5f26ea9b70193ce5c83b48964ce7f906d45de22f /scripts
parent3f89b5bf71d51fcb66ac1fb75b914c92627c95dc (diff)
Obtain branches in a more robust way. Begin refactor work on gitcommands
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/push_new_patch.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/push_new_patch.go b/scripts/push_new_patch.go
new file mode 100755
index 000000000..692a42f78
--- /dev/null
+++ b/scripts/push_new_patch.go
@@ -0,0 +1,55 @@
+// call from project root with
+// go run bin/push_new_patch.go
+
+// goreleaser expects a $GITHUB_TOKEN env variable to be defined
+// in order to push the release got github
+
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os/exec"
+ "strconv"
+ "strings"
+)
+
+func main() {
+ version, err := ioutil.ReadFile("VERSION")
+ if err != nil {
+ log.Panicln(err.Error())
+ }
+ stringVersion := string(version)
+ fmt.Println("VERSION was " + stringVersion)
+
+ runCommand("git", "pull")
+
+ splitVersion := strings.Split(stringVersion, ".")
+ patch := splitVersion[len(splitVersion)-1]
+ newPatch, err := strconv.Atoi(patch)
+ splitVersion[len(splitVersion)-1] = strconv.FormatInt(int64(newPatch)+1, 10)
+ newVersion := strings.Join(splitVersion, ".")
+
+ err = ioutil.WriteFile("VERSION", []byte(newVersion), 0644)
+ if err != nil {
+ log.Panicln(err.Error())
+ }
+
+ runCommand("git", "add", "VERSION")
+ runCommand("git", "commit", "-m", "bump version to "+newVersion, "--", "VERSION")
+ runCommand("git", "push")
+ runCommand("git", "tag", newVersion)
+ runCommand("git", "push", "origin", newVersion)
+ runCommand("goreleaser", "--rm-dist")
+ runCommand("rm", "-rf", "dist")
+}
+
+func runCommand(args ...string) {
+ fmt.Println(strings.Join(args, " "))
+ output, err := exec.Command(args[0], args[1:]...).CombinedOutput()
+ if err != nil {
+ panic(err.Error())
+ }
+ log.Print(string(output))
+}