1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/config/config.go

113 lines
2.2 KiB
Go
Raw Normal View History

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