2016-12-21 10:35:34 -02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-12-21 15:03:07 -02:00
|
|
|
"log"
|
2016-12-21 10:35:34 -02:00
|
|
|
|
2016-12-29 09:58:22 -02:00
|
|
|
"github.com/goreleaser/releaser/brew"
|
2016-12-21 11:37:31 -02:00
|
|
|
"github.com/goreleaser/releaser/build"
|
2016-12-29 09:58:22 -02:00
|
|
|
"github.com/goreleaser/releaser/compress"
|
2016-12-21 10:35:34 -02:00
|
|
|
"github.com/goreleaser/releaser/config"
|
2016-12-21 15:03:07 -02:00
|
|
|
"github.com/goreleaser/releaser/git"
|
2016-12-28 22:23:39 -02:00
|
|
|
"github.com/goreleaser/releaser/release"
|
2016-12-21 10:35:34 -02:00
|
|
|
)
|
|
|
|
|
2016-12-21 14:42:23 -02:00
|
|
|
var version = "none"
|
|
|
|
|
2016-12-21 10:35:34 -02:00
|
|
|
func main() {
|
|
|
|
config, err := config.Load("goreleaser.yml")
|
|
|
|
if err != nil {
|
2016-12-28 23:46:18 -02:00
|
|
|
log.Fatalln("Failed to load goreleaser.yml:", err.Error())
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|
2016-12-21 15:03:07 -02:00
|
|
|
tag, err := git.CurrentTag()
|
|
|
|
if err != nil {
|
2016-12-28 22:23:39 -02:00
|
|
|
log.Fatalln("Failed to get current tag name", err.Error())
|
|
|
|
}
|
|
|
|
fmt.Println("Building", tag, "...")
|
|
|
|
err = build.Build(tag, config)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Failed to diff current and previous tags", err.Error())
|
|
|
|
}
|
|
|
|
err = compress.ArchiveAll(version, config)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Failed to create archives", err.Error())
|
2016-12-21 15:03:07 -02:00
|
|
|
}
|
2016-12-28 23:39:31 -02:00
|
|
|
previousTag, err := git.PreviousTag(tag)
|
2016-12-28 22:23:39 -02:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Failed to get previous tag name", err.Error())
|
|
|
|
}
|
2016-12-21 15:03:07 -02:00
|
|
|
diff, err := git.Log(previousTag, tag)
|
|
|
|
if err != nil {
|
2016-12-28 22:23:39 -02:00
|
|
|
log.Fatalln("Failed to diff current and previous tags", err.Error())
|
|
|
|
}
|
2016-12-28 23:21:49 -02:00
|
|
|
err = release.Release(tag, diff, config)
|
2016-12-28 22:23:39 -02:00
|
|
|
if err != nil {
|
2016-12-29 09:58:22 -02:00
|
|
|
log.Fatalln("Failed to create GitHub release", err.Error())
|
2016-12-28 22:23:39 -02:00
|
|
|
}
|
|
|
|
if config.Brew.Repo != "" {
|
2016-12-29 09:58:22 -02:00
|
|
|
if err := brew.Brew(tag, config); err != nil {
|
|
|
|
log.Fatalln("Failed to create homebrew formula", err.Error())
|
|
|
|
}
|
2016-12-21 15:03:07 -02:00
|
|
|
}
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|