feat(ci): check if running on a ci, else skip release

This commit is contained in:
Nightapes
2019-07-15 21:20:44 +02:00
parent e3b54c63b0
commit 13afcea8a0
5 changed files with 169 additions and 35 deletions

38
internal/ci/git.go Normal file
View File

@@ -0,0 +1,38 @@
package ci
import (
"fmt"
"github.com/Nightapes/go-semantic-release/internal/gitutil"
"os"
)
//Git struct
type Git struct {
gitUtil *gitutil.GitUtil
}
//Detect if on Git
func (t Git) Detect() (*ProviderConfig, error) {
if _, exists := os.LookupEnv("CI"); !exists {
return nil, fmt.Errorf("running not git only")
}
hash, err := t.gitUtil.GetHash()
if err != nil {
return nil, err
}
currentBranch, err := t.gitUtil.GetBranch()
if err != nil {
return nil, err
}
return &ProviderConfig{
Service: "Git",
Name: "Git only",
Commit: hash,
Branch: currentBranch,
IsPR: false,
}, nil
}