2017-04-14 20:39:32 +02:00
|
|
|
// Package config contains the model and loader of the goreleaser configuration
|
|
|
|
// file.
|
2016-12-21 14:35:34 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2017-05-11 04:14:17 +02:00
|
|
|
"io"
|
2016-12-21 14:35:34 +02:00
|
|
|
"io/ioutil"
|
2017-05-18 14:02:02 +02:00
|
|
|
"os"
|
2017-07-08 17:05:57 +02:00
|
|
|
|
2017-06-28 01:06:45 +02:00
|
|
|
"github.com/apex/log"
|
2017-07-08 17:05:57 +02:00
|
|
|
yaml "gopkg.in/yaml.v2"
|
2016-12-21 14:35:34 +02:00
|
|
|
)
|
|
|
|
|
2017-09-26 23:33:22 +02:00
|
|
|
// GitHubURLs holds the URLs to be used when using github enterprise
|
|
|
|
type GitHubURLs struct {
|
|
|
|
API string `yaml:"api,omitempty"`
|
|
|
|
Upload string `yaml:"upload,omitempty"`
|
|
|
|
Download string `yaml:"download,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-03-23 02:01:29 +02:00
|
|
|
// Repo represents any kind of repo (github, gitlab, etc)
|
|
|
|
type Repo struct {
|
2017-09-26 23:33:22 +02:00
|
|
|
Owner string `yaml:",omitempty"`
|
|
|
|
Name string `yaml:",omitempty"`
|
2017-03-23 02:01:29 +02:00
|
|
|
}
|
|
|
|
|
2017-03-23 02:27:04 +02:00
|
|
|
// String of the repo, e.g. owner/name
|
2017-03-23 02:01:29 +02:00
|
|
|
func (r Repo) String() string {
|
2017-10-15 21:46:21 +02:00
|
|
|
if r.Owner == "" && r.Name == "" {
|
|
|
|
return ""
|
|
|
|
}
|
2017-03-23 02:01:29 +02:00
|
|
|
return r.Owner + "/" + r.Name
|
|
|
|
}
|
|
|
|
|
2017-01-15 18:37:00 +02:00
|
|
|
// Homebrew contains the brew section
|
|
|
|
type Homebrew struct {
|
2018-01-17 22:57:41 +02:00
|
|
|
GitHub Repo `yaml:",omitempty"`
|
|
|
|
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
|
|
|
Folder string `yaml:",omitempty"`
|
|
|
|
Caveats string `yaml:",omitempty"`
|
|
|
|
Plist string `yaml:",omitempty"`
|
|
|
|
Install string `yaml:",omitempty"`
|
|
|
|
Dependencies []string `yaml:",omitempty"`
|
|
|
|
Test string `yaml:",omitempty"`
|
|
|
|
Conflicts []string `yaml:",omitempty"`
|
|
|
|
Description string `yaml:",omitempty"`
|
|
|
|
Homepage string `yaml:",omitempty"`
|
|
|
|
SkipUpload bool `yaml:"skip_upload,omitempty"`
|
|
|
|
DownloadStrategy string `yaml:"download_strategy,omitempty"`
|
2016-12-21 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2018-02-10 14:38:07 +02:00
|
|
|
// Scoop contains the scoop.sh section
|
|
|
|
type Scoop struct {
|
|
|
|
Bucket Repo `yaml:",omitempty"`
|
|
|
|
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
|
|
|
Homepage string `yaml:",omitempty"`
|
|
|
|
Description string `yaml:",omitempty"`
|
|
|
|
License string `yaml:",omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-09-30 20:37:03 +02:00
|
|
|
// CommitAuthor is the author of a Git commit
|
|
|
|
type CommitAuthor struct {
|
|
|
|
Name string `yaml:",omitempty"`
|
|
|
|
Email string `yaml:",omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-01-22 00:02:51 +02:00
|
|
|
// Hooks define actions to run before and/or after something
|
|
|
|
type Hooks struct {
|
2017-04-28 18:18:32 +02:00
|
|
|
Pre string `yaml:",omitempty"`
|
|
|
|
Post string `yaml:",omitempty"`
|
2017-01-22 00:02:51 +02:00
|
|
|
}
|
|
|
|
|
2017-04-27 01:08:25 +02:00
|
|
|
// IgnoredBuild represents a build ignored by the user
|
|
|
|
type IgnoredBuild struct {
|
|
|
|
Goos, Goarch, Goarm string
|
|
|
|
}
|
|
|
|
|
2017-01-15 18:37:00 +02:00
|
|
|
// Build contains the build configuration section
|
|
|
|
type Build struct {
|
2017-05-01 17:04:31 +02:00
|
|
|
Goos []string `yaml:",omitempty"`
|
|
|
|
Goarch []string `yaml:",omitempty"`
|
|
|
|
Goarm []string `yaml:",omitempty"`
|
2018-01-22 02:44:06 +02:00
|
|
|
Targets []string `yaml:",omitempty"`
|
2017-05-01 17:04:31 +02:00
|
|
|
Ignore []IgnoredBuild `yaml:",omitempty"`
|
|
|
|
Main string `yaml:",omitempty"`
|
|
|
|
Ldflags string `yaml:",omitempty"`
|
|
|
|
Flags string `yaml:",omitempty"`
|
|
|
|
Binary string `yaml:",omitempty"`
|
|
|
|
Hooks Hooks `yaml:",omitempty"`
|
2017-05-11 15:43:25 +02:00
|
|
|
Env []string `yaml:",omitempty"`
|
2018-01-21 18:31:08 +02:00
|
|
|
Lang string `yaml:",omitempty"`
|
2016-12-21 15:37:31 +02:00
|
|
|
}
|
|
|
|
|
2017-04-21 21:01:19 +02:00
|
|
|
// FormatOverride is used to specify a custom format for a specific GOOS.
|
|
|
|
type FormatOverride struct {
|
2017-04-28 18:18:32 +02:00
|
|
|
Goos string `yaml:",omitempty"`
|
|
|
|
Format string `yaml:",omitempty"`
|
2017-04-21 21:01:19 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 18:37:00 +02:00
|
|
|
// Archive config used for the archive
|
|
|
|
type Archive struct {
|
2017-12-27 13:16:00 +02:00
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
|
|
|
Replacements map[string]string `yaml:",omitempty"`
|
|
|
|
|
|
|
|
Format string `yaml:",omitempty"`
|
|
|
|
FormatOverrides []FormatOverride `yaml:"format_overrides,omitempty"`
|
|
|
|
WrapInDirectory bool `yaml:"wrap_in_directory,omitempty"`
|
|
|
|
Files []string `yaml:",omitempty"`
|
2017-01-14 23:47:15 +02:00
|
|
|
}
|
|
|
|
|
2017-01-15 18:37:00 +02:00
|
|
|
// Release config used for the GitHub release
|
|
|
|
type Release struct {
|
2017-10-07 11:31:14 +02:00
|
|
|
GitHub Repo `yaml:",omitempty"`
|
|
|
|
Draft bool `yaml:",omitempty"`
|
|
|
|
Prerelease bool `yaml:",omitempty"`
|
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
2017-01-14 18:06:57 +02:00
|
|
|
}
|
|
|
|
|
2017-01-30 01:55:32 +02:00
|
|
|
// FPM config
|
|
|
|
type FPM struct {
|
2017-12-27 01:36:17 +02:00
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
|
|
|
Replacements map[string]string `yaml:",omitempty"`
|
2017-12-27 13:16:00 +02:00
|
|
|
|
2017-08-09 03:54:23 +02:00
|
|
|
Formats []string `yaml:",omitempty"`
|
|
|
|
Dependencies []string `yaml:",omitempty"`
|
2018-02-19 00:36:52 +02:00
|
|
|
Recommends []string `yaml:",omitempty"`
|
|
|
|
Suggests []string `yaml:",omitempty"`
|
2017-08-09 03:54:23 +02:00
|
|
|
Conflicts []string `yaml:",omitempty"`
|
|
|
|
Vendor string `yaml:",omitempty"`
|
|
|
|
Homepage string `yaml:",omitempty"`
|
|
|
|
Maintainer string `yaml:",omitempty"`
|
|
|
|
Description string `yaml:",omitempty"`
|
|
|
|
License string `yaml:",omitempty"`
|
2017-11-06 07:27:44 +02:00
|
|
|
Bindir string `yaml:",omitempty"`
|
2017-08-09 03:54:23 +02:00
|
|
|
Files map[string]string `yaml:",omitempty"`
|
2018-02-17 23:30:26 +02:00
|
|
|
ConfigFiles map[string]string `yaml:"config_files,omitempty"`
|
2017-01-30 01:55:32 +02:00
|
|
|
}
|
|
|
|
|
2017-12-13 18:14:01 +02:00
|
|
|
// Sign config
|
|
|
|
type Sign struct {
|
|
|
|
Cmd string `yaml:"cmd,omitempty"`
|
|
|
|
Args []string `yaml:"args,omitempty"`
|
|
|
|
Signature string `yaml:"signature,omitempty"`
|
|
|
|
Artifacts string `yaml:"artifacts,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-08-04 07:44:49 +02:00
|
|
|
// SnapcraftAppMetadata for the binaries that will be in the snap package
|
2017-08-04 07:42:55 +02:00
|
|
|
type SnapcraftAppMetadata struct {
|
|
|
|
Plugs []string
|
|
|
|
Daemon string
|
|
|
|
}
|
|
|
|
|
2017-07-27 02:30:48 +02:00
|
|
|
// Snapcraft config
|
|
|
|
type Snapcraft struct {
|
2017-12-27 13:16:00 +02:00
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
|
|
|
Replacements map[string]string `yaml:",omitempty"`
|
|
|
|
|
|
|
|
Name string `yaml:",omitempty"`
|
|
|
|
Summary string `yaml:",omitempty"`
|
|
|
|
Description string `yaml:",omitempty"`
|
|
|
|
Grade string `yaml:",omitempty"`
|
|
|
|
Confinement string `yaml:",omitempty"`
|
|
|
|
Apps map[string]SnapcraftAppMetadata `yaml:",omitempty"`
|
2017-07-27 02:30:48 +02:00
|
|
|
}
|
|
|
|
|
2017-04-29 12:49:22 +02:00
|
|
|
// Snapshot config
|
|
|
|
type Snapshot struct {
|
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
2017-01-30 01:55:32 +02:00
|
|
|
}
|
|
|
|
|
2017-08-28 01:45:33 +02:00
|
|
|
// Checksum config
|
|
|
|
type Checksum struct {
|
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-09-12 04:31:00 +02:00
|
|
|
// Docker image config
|
|
|
|
type Docker struct {
|
2018-01-18 21:40:44 +02:00
|
|
|
Binary string `yaml:",omitempty"`
|
|
|
|
Goos string `yaml:",omitempty"`
|
|
|
|
Goarch string `yaml:",omitempty"`
|
|
|
|
Goarm string `yaml:",omitempty"`
|
|
|
|
Image string `yaml:",omitempty"`
|
|
|
|
Dockerfile string `yaml:",omitempty"`
|
|
|
|
Latest bool `yaml:",omitempty"`
|
|
|
|
OldTagTemplate string `yaml:"tag_template,omitempty"`
|
|
|
|
TagTemplates []string `yaml:"tag_templates,omitempty"`
|
|
|
|
Files []string `yaml:"extra_files,omitempty"`
|
2017-09-12 04:31:00 +02:00
|
|
|
}
|
|
|
|
|
2017-12-02 20:41:05 +02:00
|
|
|
// Artifactory server configuration
|
|
|
|
type Artifactory struct {
|
|
|
|
Target string `yaml:",omitempty"`
|
2017-12-09 19:17:37 +02:00
|
|
|
Name string `yaml:",omitempty"`
|
2017-12-02 20:41:05 +02:00
|
|
|
Username string `yaml:",omitempty"`
|
2017-12-09 21:54:04 +02:00
|
|
|
Mode string `yaml:",omitempty"`
|
2017-12-02 20:41:05 +02:00
|
|
|
}
|
|
|
|
|
2017-10-16 00:21:35 +02:00
|
|
|
// Filters config
|
|
|
|
type Filters struct {
|
|
|
|
Exclude []string `yaml:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Changelog Config
|
|
|
|
type Changelog struct {
|
|
|
|
Filters Filters `yaml:",omitempty"`
|
2017-10-20 00:44:12 +02:00
|
|
|
Sort string `yaml:",omitempty"`
|
2017-10-16 00:21:35 +02:00
|
|
|
}
|
|
|
|
|
2018-02-03 20:47:03 +02:00
|
|
|
// EnvFiles holds paths to files that contains environment variables
|
|
|
|
// values like the github token for example
|
2018-02-03 04:06:48 +02:00
|
|
|
type EnvFiles struct {
|
|
|
|
GitHubToken string `yaml:"github_token,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-01-15 18:37:00 +02:00
|
|
|
// Project includes all project configuration
|
|
|
|
type Project struct {
|
2017-12-02 20:41:05 +02:00
|
|
|
ProjectName string `yaml:"project_name,omitempty"`
|
|
|
|
Release Release `yaml:",omitempty"`
|
|
|
|
Brew Homebrew `yaml:",omitempty"`
|
2018-02-10 14:38:07 +02:00
|
|
|
Scoop Scoop `yaml:",omitempty"`
|
2017-12-02 20:41:05 +02:00
|
|
|
Builds []Build `yaml:",omitempty"`
|
|
|
|
Archive Archive `yaml:",omitempty"`
|
|
|
|
FPM FPM `yaml:",omitempty"`
|
2018-02-17 16:16:06 +02:00
|
|
|
NFPM FPM `yaml:",omitempty"`
|
2017-12-02 20:41:05 +02:00
|
|
|
Snapcraft Snapcraft `yaml:",omitempty"`
|
|
|
|
Snapshot Snapshot `yaml:",omitempty"`
|
|
|
|
Checksum Checksum `yaml:",omitempty"`
|
|
|
|
Dockers []Docker `yaml:",omitempty"`
|
|
|
|
Artifactories []Artifactory `yaml:",omitempty"`
|
|
|
|
Changelog Changelog `yaml:",omitempty"`
|
|
|
|
Dist string `yaml:",omitempty"`
|
2017-12-13 18:14:01 +02:00
|
|
|
Sign Sign `yaml:",omitempty"`
|
2018-02-03 04:06:48 +02:00
|
|
|
EnvFiles EnvFiles `yaml:"env_files,omitempty"`
|
2017-03-26 02:29:38 +02:00
|
|
|
|
2017-07-02 02:27:30 +02:00
|
|
|
// this is a hack ¯\_(ツ)_/¯
|
|
|
|
SingleBuild Build `yaml:"build,omitempty"`
|
|
|
|
|
2017-09-26 23:33:22 +02:00
|
|
|
// should be set if using github enterprise
|
|
|
|
GitHubURLs GitHubURLs `yaml:"github_urls,omitempty"`
|
2016-12-21 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2016-12-30 16:41:59 +02:00
|
|
|
// Load config file
|
2017-01-15 18:37:00 +02:00
|
|
|
func Load(file string) (config Project, err error) {
|
2017-05-18 14:02:02 +02:00
|
|
|
f, err := os.Open(file)
|
2016-12-21 14:35:34 +02:00
|
|
|
if err != nil {
|
2017-05-18 14:02:02 +02:00
|
|
|
return
|
2016-12-21 14:35:34 +02:00
|
|
|
}
|
2017-07-05 04:51:45 +02:00
|
|
|
log.WithField("file", file).Info("loading config file")
|
2017-05-18 14:02:02 +02:00
|
|
|
return LoadReader(f)
|
2016-12-31 12:53:48 +02:00
|
|
|
}
|
2017-05-11 04:14:17 +02:00
|
|
|
|
2017-05-18 14:02:02 +02:00
|
|
|
// LoadReader config via io.Reader
|
2017-05-11 04:14:17 +02:00
|
|
|
func LoadReader(fd io.Reader) (config Project, err error) {
|
|
|
|
data, err := ioutil.ReadAll(fd)
|
|
|
|
if err != nil {
|
2017-05-11 04:35:44 +02:00
|
|
|
return config, err
|
|
|
|
}
|
2018-01-26 18:38:16 +02:00
|
|
|
err = yaml.UnmarshalStrict(data, &config)
|
2017-07-02 02:27:30 +02:00
|
|
|
log.WithField("config", config).Debug("loaded config file")
|
2018-01-26 18:38:16 +02:00
|
|
|
return config, err
|
2017-07-08 17:05:57 +02:00
|
|
|
}
|