mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
golint
This commit is contained in:
parent
9a67478c0d
commit
d9c8c5f499
@ -9,36 +9,41 @@ import (
|
||||
yaml "gopkg.in/yaml.v1"
|
||||
)
|
||||
|
||||
var emptyBrew = HomebrewDeploy{}
|
||||
var emptyBrew = Homebrew{}
|
||||
|
||||
type HomebrewDeploy struct {
|
||||
// Homebrew contains the brew section
|
||||
type Homebrew struct {
|
||||
Repo string
|
||||
Token string
|
||||
Caveats string
|
||||
}
|
||||
|
||||
// BuildConfig contains the build configuration section
|
||||
type BuildConfig struct {
|
||||
Oses []string
|
||||
Arches []string
|
||||
Main string
|
||||
}
|
||||
|
||||
// GitInfo includes tags and diffs used in some point
|
||||
type GitInfo struct {
|
||||
CurrentTag string
|
||||
PreviousTag string
|
||||
Diff string
|
||||
}
|
||||
|
||||
// ProjectConfig includes all project configuration
|
||||
type ProjectConfig struct {
|
||||
Repo string
|
||||
BinaryName string `yaml:"binary_name"`
|
||||
Files []string
|
||||
Brew HomebrewDeploy
|
||||
Brew Homebrew
|
||||
Token string
|
||||
Build BuildConfig
|
||||
Git GitInfo `yaml:"_"`
|
||||
}
|
||||
|
||||
// Load config file
|
||||
func Load(file string) (config ProjectConfig, err error) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestFixConfig(t *testing.T) {
|
||||
|
@ -2,6 +2,7 @@ package git
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// Log between two tags
|
||||
func Log(previous, current string) (str string, err error) {
|
||||
cmd := exec.Command(
|
||||
"git",
|
||||
|
@ -6,10 +6,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CurrentTag tag being built
|
||||
func CurrentTag() (tag string, err error) {
|
||||
return getTag("")
|
||||
}
|
||||
|
||||
// PreviousTag previous tag of the base tag
|
||||
func PreviousTag(base string) (tag string, err error) {
|
||||
return getTag(base + "^")
|
||||
}
|
||||
|
2
main.go
2
main.go
@ -25,7 +25,7 @@ func main() {
|
||||
brew.Pipe{},
|
||||
}
|
||||
for _, pipe := range pipeline {
|
||||
if err := pipe.Work(config); err != nil {
|
||||
if err := pipe.Run(config); err != nil {
|
||||
log.Fatalln(pipe.Name(), "failed:", err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -36,13 +36,16 @@ type templateData struct {
|
||||
Name, Desc, Homepage, Repo, Tag, BinaryName, Caveats string
|
||||
}
|
||||
|
||||
// Pipe for brew deployment
|
||||
type Pipe struct{}
|
||||
|
||||
// Name of the pipe
|
||||
func (Pipe) Name() string {
|
||||
return "Homebrew"
|
||||
}
|
||||
|
||||
func (Pipe) Work(config config.ProjectConfig) error {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(config config.ProjectConfig) error {
|
||||
if config.Brew.Repo == "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -12,13 +12,16 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Pipe for build
|
||||
type Pipe struct{}
|
||||
|
||||
// Name of the pipe
|
||||
func (Pipe) Name() string {
|
||||
return "Build"
|
||||
}
|
||||
|
||||
func (Pipe) Work(config config.ProjectConfig) error {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(config config.ProjectConfig) error {
|
||||
var g errgroup.Group
|
||||
for _, system := range config.Build.Oses {
|
||||
for _, arch := range config.Build.Arches {
|
||||
|
@ -12,13 +12,16 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Pipe for compress
|
||||
type Pipe struct{}
|
||||
|
||||
// Name of the pipe
|
||||
func (Pipe) Name() string {
|
||||
return "Compress"
|
||||
}
|
||||
|
||||
func (Pipe) Work(config config.ProjectConfig) error {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(config config.ProjectConfig) error {
|
||||
var g errgroup.Group
|
||||
for _, system := range config.Build.Oses {
|
||||
for _, arch := range config.Build.Arches {
|
||||
|
@ -2,7 +2,11 @@ package pipeline
|
||||
|
||||
import "github.com/goreleaser/releaser/config"
|
||||
|
||||
// Pipe interface
|
||||
type Pipe interface {
|
||||
// Name of the pipe
|
||||
Name() string
|
||||
Work(config config.ProjectConfig) error
|
||||
|
||||
// Run the pipe
|
||||
Run(config config.ProjectConfig) error
|
||||
}
|
||||
|
@ -14,13 +14,16 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Pipe for github release
|
||||
type Pipe struct{}
|
||||
|
||||
// Name of the pipe
|
||||
func (Pipe) Name() string {
|
||||
return "GithubRelease"
|
||||
}
|
||||
|
||||
func (Pipe) Work(config config.ProjectConfig) error {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(config config.ProjectConfig) error {
|
||||
log.Println("Creating release", config.Git.CurrentTag, "on", config.Repo, "...")
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: config.Token},
|
||||
|
@ -2,6 +2,7 @@ package split
|
||||
|
||||
import "strings"
|
||||
|
||||
// OnSlash split a string on / and return the first 2 parts
|
||||
func OnSlash(pair string) (string, string) {
|
||||
parts := strings.Split(pair, "/")
|
||||
return parts[0], parts[1]
|
||||
|
@ -10,6 +10,7 @@ var mapping = map[string]string{
|
||||
"amd64": "x86_64",
|
||||
}
|
||||
|
||||
// FromGo translates GOOS and GOARCH to uname compatibles
|
||||
func FromGo(s string) string {
|
||||
result := mapping[s]
|
||||
if result == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user