2017-04-14 15:39:32 -03:00
|
|
|
// Package config contains the model and loader of the goreleaser configuration
|
|
|
|
// file.
|
2016-12-21 10:35:34 -02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v1"
|
|
|
|
)
|
|
|
|
|
2017-03-22 21:01:29 -03:00
|
|
|
// Repo represents any kind of repo (github, gitlab, etc)
|
|
|
|
type Repo struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
Owner string `yaml:",omitempty"`
|
|
|
|
Name string `yaml:",omitempty"`
|
2017-03-22 21:01:29 -03:00
|
|
|
}
|
|
|
|
|
2017-03-22 21:27:04 -03:00
|
|
|
// String of the repo, e.g. owner/name
|
2017-03-22 21:01:29 -03:00
|
|
|
func (r Repo) String() string {
|
|
|
|
return r.Owner + "/" + r.Name
|
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Homebrew contains the brew section
|
|
|
|
type Homebrew struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
GitHub Repo `yaml:",omitempty"`
|
|
|
|
Folder string `yaml:",omitempty"`
|
|
|
|
Caveats string `yaml:",omitempty"`
|
|
|
|
Plist string `yaml:",omitempty"`
|
|
|
|
Install string `yaml:",omitempty"`
|
|
|
|
Dependencies []string `yaml:",omitempty"`
|
|
|
|
Conflicts []string `yaml:",omitempty"`
|
|
|
|
Description string `yaml:",omitempty"`
|
|
|
|
Homepage string `yaml:",omitempty"`
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|
|
|
|
|
2017-01-21 20:02:51 -02:00
|
|
|
// Hooks define actions to run before and/or after something
|
|
|
|
type Hooks struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
Pre string `yaml:",omitempty"`
|
|
|
|
Post string `yaml:",omitempty"`
|
2017-01-21 20:02:51 -02:00
|
|
|
}
|
|
|
|
|
2017-04-26 20:08:25 -03:00
|
|
|
// IgnoredBuild represents a build ignored by the user
|
|
|
|
type IgnoredBuild struct {
|
|
|
|
Goos, Goarch, Goarm string
|
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Build contains the build configuration section
|
|
|
|
type Build struct {
|
2017-05-01 11:41:30 -03:00
|
|
|
Goos []string `yaml:",omitempty"`
|
|
|
|
Goarch []string `yaml:",omitempty"`
|
|
|
|
Goarm []string `yaml:",omitempty"`
|
|
|
|
Ignore []IgnoredBuild `yaml:",omitempty"`
|
|
|
|
Main string `yaml:",omitempty"`
|
|
|
|
Ldflags string `yaml:",omitempty"`
|
|
|
|
Flags string `yaml:",omitempty"`
|
|
|
|
Binary string `yaml:",omitempty"`
|
|
|
|
Hooks Hooks `yaml:",omitempty"`
|
2016-12-21 11:37:31 -02:00
|
|
|
}
|
|
|
|
|
2017-04-21 16:01:19 -03:00
|
|
|
// FormatOverride is used to specify a custom format for a specific GOOS.
|
|
|
|
type FormatOverride struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
Goos string `yaml:",omitempty"`
|
|
|
|
Format string `yaml:",omitempty"`
|
2017-04-21 16:01:19 -03:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Archive config used for the archive
|
|
|
|
type Archive struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
Format string `yaml:",omitempty"`
|
2017-04-28 13:25:29 +02:00
|
|
|
FormatOverrides []FormatOverride `yaml:"format_overrides,omitempty"`
|
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
2017-04-28 13:18:32 -03:00
|
|
|
Replacements map[string]string `yaml:",omitempty"`
|
|
|
|
Files []string `yaml:",omitempty"`
|
2017-01-14 19:47:15 -02:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Release config used for the GitHub release
|
|
|
|
type Release struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
GitHub Repo `yaml:",omitempty"`
|
|
|
|
Draft bool `yaml:",omitempty"`
|
2017-01-14 14:06:57 -02:00
|
|
|
}
|
|
|
|
|
2017-01-29 21:55:32 -02:00
|
|
|
// FPM config
|
|
|
|
type FPM struct {
|
2017-04-28 13:18:32 -03:00
|
|
|
Formats []string `yaml:",omitempty"`
|
|
|
|
Dependencies []string `yaml:",omitempty"`
|
|
|
|
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-01-29 21:55:32 -02:00
|
|
|
}
|
|
|
|
|
2017-04-29 12:49:22 +02:00
|
|
|
// Snapshot config
|
|
|
|
type Snapshot struct {
|
|
|
|
NameTemplate string `yaml:"name_template,omitempty"`
|
2017-01-29 21:55:32 -02:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Project includes all project configuration
|
|
|
|
type Project struct {
|
2017-04-29 12:49:22 +02:00
|
|
|
Release Release `yaml:",omitempty"`
|
|
|
|
Brew Homebrew `yaml:",omitempty"`
|
|
|
|
Build Build `yaml:",omitempty"`
|
|
|
|
Archive Archive `yaml:",omitempty"`
|
|
|
|
FPM FPM `yaml:",omitempty"`
|
|
|
|
Snapshot Snapshot `yaml:",omitempty"`
|
2017-03-25 21:29:38 -03:00
|
|
|
|
2017-03-25 21:31:41 -03:00
|
|
|
// test only property indicating the path to the dist folder
|
2017-03-25 21:31:16 -03:00
|
|
|
Dist string `yaml:"-"`
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|
|
|
|
|
2016-12-30 12:41:59 -02:00
|
|
|
// Load config file
|
2017-01-15 14:37:00 -02:00
|
|
|
func Load(file string) (config Project, err error) {
|
2016-12-21 10:35:34 -02:00
|
|
|
data, err := ioutil.ReadFile(file)
|
|
|
|
if err != nil {
|
|
|
|
return config, err
|
|
|
|
}
|
2017-01-14 12:34:22 -02:00
|
|
|
err = yaml.Unmarshal(data, &config)
|
2016-12-31 10:53:48 +00:00
|
|
|
return
|
|
|
|
}
|