2016-12-21 10:35:34 -02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v1"
|
|
|
|
)
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Homebrew contains the brew section
|
|
|
|
type Homebrew struct {
|
2017-01-17 08:33:43 -02:00
|
|
|
Repo string
|
|
|
|
Folder string
|
|
|
|
Caveats string
|
2017-02-21 16:04:57 +01:00
|
|
|
Plist string
|
2017-01-17 08:33:43 -02:00
|
|
|
Dependencies []string
|
2017-02-01 15:40:27 -02:00
|
|
|
Conflicts []string
|
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 {
|
|
|
|
Pre string
|
|
|
|
Post string
|
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Build contains the build configuration section
|
|
|
|
type Build struct {
|
2017-01-14 19:47:15 -02:00
|
|
|
Goos []string
|
|
|
|
Goarch []string
|
|
|
|
Main string
|
|
|
|
Ldflags string
|
2017-02-22 09:25:43 -03:00
|
|
|
Flags string
|
2017-01-14 19:47:15 -02:00
|
|
|
BinaryName string `yaml:"binary_name"`
|
2017-01-21 20:02:51 -02:00
|
|
|
Hooks Hooks
|
2016-12-21 11:37:31 -02:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Archive config used for the archive
|
|
|
|
type Archive struct {
|
2017-01-14 14:06:57 -02:00
|
|
|
Format string
|
|
|
|
NameTemplate string `yaml:"name_template"`
|
|
|
|
Replacements map[string]string
|
2017-01-14 19:47:15 -02:00
|
|
|
Files []string
|
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Release config used for the GitHub release
|
|
|
|
type Release struct {
|
2017-01-14 19:47:15 -02:00
|
|
|
Repo string
|
2017-01-14 14:06:57 -02:00
|
|
|
}
|
|
|
|
|
2017-01-29 21:55:32 -02:00
|
|
|
// FPM config
|
|
|
|
type FPM struct {
|
2017-01-29 22:33:08 -02:00
|
|
|
Formats []string
|
|
|
|
Dependencies []string
|
2017-02-01 15:40:27 -02:00
|
|
|
Conflicts []string
|
2017-01-29 21:55:32 -02:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:37:00 -02:00
|
|
|
// Project includes all project configuration
|
|
|
|
type Project struct {
|
|
|
|
Release Release
|
|
|
|
Brew Homebrew
|
|
|
|
Build Build
|
|
|
|
Archive Archive
|
2017-01-29 21:55:32 -02:00
|
|
|
FPM FPM `yaml:"fpm"`
|
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
|
|
|
|
}
|