2019-05-15 22:09:52 +02:00
|
|
|
// Package config provides defimition of .release.yml and read method
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ChangelogConfig struct
|
|
|
|
|
type ChangelogConfig struct {
|
2019-05-25 18:10:24 +02:00
|
|
|
PrintAll bool `yaml:"printAll,omitempty"`
|
2019-05-15 22:09:52 +02:00
|
|
|
Template string `yaml:"template,omitempty"`
|
|
|
|
|
TemplatePath string `yaml:"templatePath,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 19:47:04 +02:00
|
|
|
//Asset type struct
|
2019-05-28 22:12:00 +02:00
|
|
|
type Asset struct {
|
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
|
Compress bool `yaml:"compress"`
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 23:03:27 +02:00
|
|
|
// GitHubProvider struct
|
|
|
|
|
type GitHubProvider struct {
|
|
|
|
|
Repo string `yaml:"repo"`
|
|
|
|
|
User string `yaml:"user"`
|
|
|
|
|
CustomURL string `yaml:"customUrl,omitempty"`
|
|
|
|
|
AccessToken string
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-07 23:24:13 +02:00
|
|
|
// GitLabProvider struct
|
|
|
|
|
type GitLabProvider struct {
|
|
|
|
|
Repo string `yaml:"repo"`
|
|
|
|
|
CustomURL string `yaml:"customUrl,omitempty"`
|
|
|
|
|
AccessToken string
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-15 22:09:52 +02:00
|
|
|
// ReleaseConfig struct
|
|
|
|
|
type ReleaseConfig struct {
|
2019-08-13 23:01:38 +02:00
|
|
|
CommitFormat string `yaml:"commitFormat"`
|
|
|
|
|
Branch map[string]string `yaml:"branch"`
|
|
|
|
|
Changelog ChangelogConfig `yaml:"changelog,omitempty"`
|
|
|
|
|
Release string `yaml:"release,omitempty"`
|
|
|
|
|
GitHubProvider GitHubProvider `yaml:"github,omitempty"`
|
|
|
|
|
GitLabProvider GitLabProvider `yaml:"gitlab,omitempty"`
|
|
|
|
|
Assets []Asset `yaml:"assets"`
|
|
|
|
|
ReleaseTitle string `yaml:"title"`
|
|
|
|
|
IsPreRelease bool
|
2019-05-15 22:09:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read ReleaseConfig
|
|
|
|
|
func Read(configPath string) (*ReleaseConfig, error) {
|
|
|
|
|
|
|
|
|
|
content, err := ioutil.ReadFile(configPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return &ReleaseConfig{}, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var releaseConfig ReleaseConfig
|
|
|
|
|
err = yaml.Unmarshal(content, &releaseConfig)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return &ReleaseConfig{}, err
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 22:14:03 +02:00
|
|
|
log.Tracef("Found config %+v", releaseConfig)
|
2019-05-15 22:09:52 +02:00
|
|
|
|
2019-06-10 16:24:44 +02:00
|
|
|
return &releaseConfig, nil
|
2019-05-15 22:09:52 +02:00
|
|
|
}
|