mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-18 03:56:52 +02:00
git tags and diff
This commit is contained in:
parent
d8bb50f799
commit
2aa160ffca
18
git/log.go
Normal file
18
git/log.go
Normal file
@ -0,0 +1,18 @@
|
||||
package git
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func Log(previous, current string) (str string, err error) {
|
||||
cmd := exec.Command(
|
||||
"git",
|
||||
"log",
|
||||
"--pretty=oneline",
|
||||
"--abbrev-commit",
|
||||
previous+".."+current,
|
||||
)
|
||||
bts, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return str, err
|
||||
}
|
||||
return string(bts), err
|
||||
}
|
34
git/tag.go
Normal file
34
git/tag.go
Normal file
@ -0,0 +1,34 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func CurrentTag() (tag string, err error) {
|
||||
return getTag("master")
|
||||
}
|
||||
|
||||
func PreviousTag() (tag string, err error) {
|
||||
current, err := CurrentTag()
|
||||
if err != nil {
|
||||
return tag, err
|
||||
}
|
||||
return getTag(current + "^")
|
||||
}
|
||||
|
||||
func getTag(ref string) (tag string, err error) {
|
||||
cmd := exec.Command(
|
||||
"git",
|
||||
"describe",
|
||||
"--tags",
|
||||
"--abbrev=0",
|
||||
"--always",
|
||||
ref,
|
||||
)
|
||||
bts, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return tag, err
|
||||
}
|
||||
return strings.Split(string(bts), "\n")[0], err
|
||||
}
|
15
main.go
15
main.go
@ -2,9 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/goreleaser/releaser/build"
|
||||
"github.com/goreleaser/releaser/config"
|
||||
"github.com/goreleaser/releaser/git"
|
||||
)
|
||||
|
||||
var version = "none"
|
||||
@ -14,6 +16,17 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = build.Build("master", config)
|
||||
tag, err := git.CurrentTag()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
previousTag, err := git.PreviousTag()
|
||||
diff, err := git.Log(previousTag, tag)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Println(diff)
|
||||
fmt.Println("Building", tag, "...")
|
||||
err = build.Build(tag, config)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user