mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-07 13:31:37 +02:00
fixes
This commit is contained in:
parent
09dda77687
commit
d13667d173
@ -115,7 +115,7 @@ func (config *ProjectConfig) fillBasicData() {
|
||||
}
|
||||
if config.NameTemplate == "" {
|
||||
config.NameTemplate = "{{.BinaryName}}_{{.Os}}_{{.Arch}}"
|
||||
}
|
||||
}
|
||||
if config.Archive.Format == "" {
|
||||
config.Archive.Format = "tar.gz"
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ const formulae = `class {{ .Name }} < Formula
|
||||
desc "{{ .Desc }}"
|
||||
homepage "{{ .Homepage }}"
|
||||
url "https://github.com/{{ .Repo }}/releases/download/{{ .Tag }}/{{ .File }}.{{ .Format }}"
|
||||
head "https://github.com/{{ .Repo }}.git"
|
||||
version "{{ .Tag }}"
|
||||
sha256 "{{ .SHA256 }}"
|
||||
|
||||
@ -123,7 +122,11 @@ func dataFor(config config.ProjectConfig, client *github.Client) (result templat
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sum, err := sha256sum.For("dist/" + config.BinaryName + "_Darwin_x86_64." + config.Archive.Format)
|
||||
file, err := name.For(config, "darwin", "amd64")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sum, err := sha256sum.For("dist/" + file + config.Archive.Format)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -137,10 +140,6 @@ func dataFor(config config.ProjectConfig, client *github.Client) (result templat
|
||||
} else {
|
||||
description = *rep.Description
|
||||
}
|
||||
file, err := fileName(config)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
return templateData{
|
||||
Name: formulaNameFor(config.BinaryName),
|
||||
Desc: description,
|
||||
@ -155,14 +154,6 @@ func dataFor(config config.ProjectConfig, client *github.Client) (result templat
|
||||
}, err
|
||||
}
|
||||
|
||||
func fileName(config config.ProjectConfig) (string, error) {
|
||||
return name.For(
|
||||
config,
|
||||
"#{%x(uname -s).gsub(/\n/, '')}",
|
||||
"#{%x(uname -m).gsub(/\n/, '')}",
|
||||
)
|
||||
}
|
||||
|
||||
func formulaNameFor(name string) string {
|
||||
name = strings.Replace(name, "-", " ", -1)
|
||||
name = strings.Replace(name, "_", " ", -1)
|
||||
|
@ -3,7 +3,6 @@ package brew
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/releaser/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -26,7 +25,7 @@ var defaultTemplateData = templateData{
|
||||
Name: "Test",
|
||||
Repo: "caarlos0/test",
|
||||
Tag: "v0.1.3",
|
||||
File: "test_#{%x(uname -s).gsub(/\\n/, '')}_#{%x(uname -m).gsub(/\\n/, '')}",
|
||||
File: "test_Darwin_x86_64",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||
Format: "tar.gz",
|
||||
}
|
||||
@ -62,16 +61,3 @@ func TestFormulaeNoCaveats(t *testing.T) {
|
||||
assertDefaultTemplateData(t, formulae)
|
||||
assert.NotContains(formulae, "def caveats")
|
||||
}
|
||||
|
||||
func TestFilename(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
name, err := fileName(config.ProjectConfig{
|
||||
BinaryName: "test",
|
||||
NameTemplate: "{{.BinaryName}}_{{.Os}}_{{.Arch}}",
|
||||
Git: config.GitInfo{
|
||||
CurrentTag: "v1.2.3",
|
||||
},
|
||||
})
|
||||
assert.NoError(err)
|
||||
assert.Equal("test_#{%x(uname -s).gsub(/\n/, '')}_#{%x(uname -m).gsub(/\n/, '')}", name)
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"github.com/goreleaser/releaser/name"
|
||||
"github.com/goreleaser/releaser/pipeline/compress/tar"
|
||||
"github.com/goreleaser/releaser/pipeline/compress/zip"
|
||||
"github.com/goreleaser/releaser/uname"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
@ -58,7 +57,7 @@ func create(system, arch string, config config.ProjectConfig) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return addFile(tw, config.BinaryName+extFor(system), "dist/"+name+"/"+config.BinaryName)
|
||||
return archive.Add(config.BinaryName+extFor(system), "dist/"+name+"/"+config.BinaryName)
|
||||
}
|
||||
|
||||
func archiveFor(file *os.File, format string) Archive {
|
||||
|
@ -65,10 +65,10 @@ func description(diff string) string {
|
||||
|
||||
func upload(client *github.Client, releaseID int, system, arch string, config config.ProjectConfig) error {
|
||||
owner, repo := split.OnSlash(config.Repo)
|
||||
name, err := name.For(config, system, arch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name, err := name.For(config, system, arch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name = name + "." + config.Archive.Format
|
||||
file, err := os.Open("dist/" + name)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user