2018-08-09 04:10:22 +02:00
|
|
|
// 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"
|
2018-08-11 09:07:56 +02:00
|
|
|
"os"
|
2018-08-09 04:10:22 +02:00
|
|
|
"os/exec"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-08-11 09:07:56 +02:00
|
|
|
|
2018-08-09 04:10:22 +02:00
|
|
|
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")
|
2018-08-09 11:02:16 +02:00
|
|
|
runCommand("git", "commit", "-m", "bump version to "+newVersion, "--", "VERSION")
|
2018-08-09 04:10:22 +02:00
|
|
|
runCommand("git", "push")
|
|
|
|
runCommand("git", "tag", newVersion)
|
|
|
|
runCommand("git", "push", "origin", newVersion)
|
|
|
|
runCommand("goreleaser", "--rm-dist")
|
2018-08-09 07:47:55 +02:00
|
|
|
runCommand("rm", "-rf", "dist")
|
2018-08-09 04:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func runCommand(args ...string) {
|
|
|
|
fmt.Println(strings.Join(args, " "))
|
2018-08-11 09:07:56 +02:00
|
|
|
cmd := exec.Command(args[0], args[1:]...)
|
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
err := cmd.Start()
|
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
err = cmd.Wait()
|
2018-08-09 04:10:22 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
}
|