feat(releaser): add git only as releaser, will create a new tag with version only

This commit is contained in:
Nightapes
2020-01-05 18:41:44 +01:00
parent 6211095c38
commit 42fc522a43
19 changed files with 284 additions and 109 deletions

View File

@@ -3,6 +3,7 @@ package config
import (
"io/ioutil"
"os"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
@@ -50,6 +51,20 @@ type GitLabProvider struct {
AccessToken string
}
// GitProvider struct
type GitProvider struct {
Email string `yaml:"email"`
Username string `yaml:"user"`
Auth string `yaml:"auth"`
SSH bool `yaml:"ssh"`
}
// Hooks struct
type Hooks struct {
PreRelease []string `yaml:"preRelease"`
PostRelease []string `yaml:"postRelease"`
}
// ReleaseConfig struct
type ReleaseConfig struct {
CommitFormat string `yaml:"commitFormat"`
@@ -58,7 +73,9 @@ type ReleaseConfig struct {
Release string `yaml:"release,omitempty"`
GitHubProvider GitHubProvider `yaml:"github,omitempty"`
GitLabProvider GitLabProvider `yaml:"gitlab,omitempty"`
GitProvider GitProvider `yaml:"git,omitempty"`
Assets []Asset `yaml:"assets"`
Hooks Hooks `yaml:"hooks"`
ReleaseTitle string `yaml:"title"`
IsPreRelease bool
}
@@ -71,13 +88,31 @@ func Read(configPath string) (*ReleaseConfig, error) {
return &ReleaseConfig{}, err
}
var releaseConfig ReleaseConfig
err = yaml.Unmarshal(content, &releaseConfig)
log.Tracef("Found config %s", string(content))
releaseConfig := &ReleaseConfig{}
err = yaml.Unmarshal(content, releaseConfig)
if err != nil {
return &ReleaseConfig{}, err
}
log.Tracef("Found config %+v", releaseConfig)
org := *releaseConfig
return &releaseConfig, nil
releaseConfig.Hooks = Hooks{}
configWithoutHooks, err := yaml.Marshal(releaseConfig)
if err != nil {
return &ReleaseConfig{}, err
}
configWithoutHooks = []byte(os.ExpandEnv(string(configWithoutHooks)))
releaseConfigWithExpanedEnvs := &ReleaseConfig{}
err = yaml.Unmarshal(configWithoutHooks, releaseConfigWithExpanedEnvs)
if err != nil {
return &ReleaseConfig{}, err
}
releaseConfigWithExpanedEnvs.Hooks = org.Hooks
log.Tracef("Found config %+v", releaseConfigWithExpanedEnvs)
return releaseConfigWithExpanedEnvs, nil
}