mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: aur error messages (#2880)
* fix: aur error messages Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * fix: more renames Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
9cc1bb1595
commit
17aba5ce76
@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
pkgBuildExtra = "AURConfig"
|
||||
aurExtra = "AURConfig"
|
||||
defaultSSHCommand = "ssh -i {{ .KeyPath }} -o StrictHostKeyChecking=accept-new -F /dev/null"
|
||||
defaultCommitMsg = "Update to {{ .Tag }}"
|
||||
)
|
||||
@ -78,8 +78,8 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
}
|
||||
|
||||
func runAll(ctx *context.Context, cli client.Client) error {
|
||||
for _, pkgbuild := range ctx.Config.AURs {
|
||||
err := doRun(ctx, pkgbuild, cli)
|
||||
for _, aur := range ctx.Config.AURs {
|
||||
err := doRun(ctx, aur, cli)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -87,12 +87,12 @@ func runAll(ctx *context.Context, cli client.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
name, err := tmpl.New(ctx).Apply(pkgbuild.Name)
|
||||
func doRun(ctx *context.Context, aur config.AUR, cl client.Client) error {
|
||||
name, err := tmpl.New(ctx).Apply(aur.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkgbuild.Name = name
|
||||
aur.Name = name
|
||||
|
||||
filters := []artifact.Filter{
|
||||
artifact.ByGoos("linux"),
|
||||
@ -113,8 +113,8 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
artifact.ByType(artifact.UploadableBinary),
|
||||
),
|
||||
}
|
||||
if len(pkgbuild.IDs) > 0 {
|
||||
filters = append(filters, artifact.ByIDs(pkgbuild.IDs...))
|
||||
if len(aur.IDs) > 0 {
|
||||
filters = append(filters, artifact.ByIDs(aur.IDs...))
|
||||
}
|
||||
|
||||
archives := ctx.Artifacts.Filter(artifact.And(filters...)).List()
|
||||
@ -122,7 +122,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
return ErrNoArchivesFound
|
||||
}
|
||||
|
||||
pkg, err := tmpl.New(ctx).Apply(pkgbuild.Package)
|
||||
pkg, err := tmpl.New(ctx).Apply(aur.Package)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -141,7 +141,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
}
|
||||
log.Warnf("guessing package to be %q", pkg)
|
||||
}
|
||||
pkgbuild.Package = pkg
|
||||
aur.Package = pkg
|
||||
|
||||
for _, info := range []struct {
|
||||
name, tpl, ext string
|
||||
@ -149,7 +149,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
}{
|
||||
{
|
||||
name: "PKGBUILD",
|
||||
tpl: pkgBuildTemplate,
|
||||
tpl: aurTemplateData,
|
||||
ext: ".pkgbuild",
|
||||
kind: artifact.PkgBuild,
|
||||
},
|
||||
@ -160,12 +160,12 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
kind: artifact.SrcInfo,
|
||||
},
|
||||
} {
|
||||
pkgContent, err := buildPkgFile(ctx, pkgbuild, cl, archives, info.tpl)
|
||||
pkgContent, err := buildPkgFile(ctx, aur, cl, archives, info.tpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := filepath.Join(ctx.Config.Dist, "aur", pkgbuild.Name+info.ext)
|
||||
path := filepath.Join(ctx.Config.Dist, "aur", aur.Name+info.ext)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
return fmt.Errorf("failed to write %s: %w", info.kind, err)
|
||||
}
|
||||
@ -179,8 +179,8 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
|
||||
Path: path,
|
||||
Type: info.kind,
|
||||
Extra: map[string]interface{}{
|
||||
pkgBuildExtra: pkgbuild,
|
||||
artifact.ExtraID: pkgbuild.Name,
|
||||
aurExtra: aur,
|
||||
artifact.ExtraID: aur.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -346,10 +346,10 @@ func (Pipe) Publish(ctx *context.Context) error {
|
||||
}
|
||||
|
||||
func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
|
||||
cfg := pkgs[0].Extra[pkgBuildExtra].(config.AUR)
|
||||
cfg := pkgs[0].Extra[aurExtra].(config.AUR)
|
||||
|
||||
if strings.TrimSpace(cfg.SkipUpload) == "true" {
|
||||
return pipe.Skip("pkgbuild.skip_upload is set")
|
||||
return pipe.Skip("aur.skip_upload is set")
|
||||
}
|
||||
|
||||
if strings.TrimSpace(cfg.SkipUpload) == "auto" && ctx.Semver.Prerelease != "" {
|
||||
@ -372,7 +372,7 @@ func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
|
||||
}
|
||||
|
||||
if url == "" {
|
||||
return pipe.Skip("pkgbuild.git_url is empty")
|
||||
return pipe.Skip("aur.git_url is empty")
|
||||
}
|
||||
|
||||
sshcmd, err := tmpl.New(ctx).WithExtraFields(tmpl.Fields{
|
||||
@ -442,7 +442,7 @@ func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
|
||||
|
||||
func keyPath(key string) (string, error) {
|
||||
if key == "" {
|
||||
return "", pipe.Skip("pkgbuild.private_key is empty")
|
||||
return "", pipe.Skip("aur.private_key is empty")
|
||||
}
|
||||
if _, err := ssh.ParsePrivateKey([]byte(key)); err == nil {
|
||||
f, err := os.CreateTemp("", "id_*")
|
||||
|
@ -88,18 +88,18 @@ func createTemplateData() templateData {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFullPkgBuild(t *testing.T) {
|
||||
func TestFullAur(t *testing.T) {
|
||||
data := createTemplateData()
|
||||
pkg, err := applyTemplate(context.New(config.Project{
|
||||
ProjectName: "foo",
|
||||
}), pkgBuildTemplate, data)
|
||||
}), aurTemplateData, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
golden.RequireEqual(t, []byte(pkg))
|
||||
}
|
||||
|
||||
func TestPkgBuildSimple(t *testing.T) {
|
||||
pkg, err := applyTemplate(context.New(config.Project{}), pkgBuildTemplate, createTemplateData())
|
||||
func TestAurSimple(t *testing.T) {
|
||||
pkg, err := applyTemplate(context.New(config.Project{}), aurTemplateData, createTemplateData())
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, pkg, `# Maintainer: Ciclano <ciclano@example.com>`)
|
||||
require.Contains(t, pkg, `# Maintainer: Cicrano <cicrano@example.com>`)
|
||||
@ -193,7 +193,7 @@ func TestFullPipe(t *testing.T) {
|
||||
prepare: func(ctx *context.Context) {
|
||||
ctx.Config.AURs[0].PrivateKey = ""
|
||||
},
|
||||
expectedPublishError: `pkgbuild.private_key is empty`,
|
||||
expectedPublishError: `aur.private_key is empty`,
|
||||
},
|
||||
"key-not-found": {
|
||||
prepare: func(ctx *context.Context) {
|
||||
@ -211,7 +211,7 @@ func TestFullPipe(t *testing.T) {
|
||||
prepare: func(ctx *context.Context) {
|
||||
ctx.Config.AURs[0].GitURL = ""
|
||||
},
|
||||
expectedPublishError: `pkgbuild.git_url is empty`,
|
||||
expectedPublishError: `aur.git_url is empty`,
|
||||
},
|
||||
"invalid-ssh-cmd-template": {
|
||||
prepare: func(ctx *context.Context) {
|
||||
@ -338,7 +338,7 @@ func TestRunPipe(t *testing.T) {
|
||||
AURs: []config.AUR{
|
||||
{
|
||||
License: "MIT",
|
||||
Description: "A run pipe test pkgbuild and FOO={{ .Env.FOO }}",
|
||||
Description: "A run pipe test aur and FOO={{ .Env.FOO }}",
|
||||
Homepage: "https://github.com/goreleaser",
|
||||
IDs: []string{"foo"},
|
||||
GitURL: url,
|
||||
@ -731,7 +731,7 @@ func TestKeyPath(t *testing.T) {
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
result, err := keyPath("")
|
||||
require.EqualError(t, err, `pkgbuild.private_key is empty`)
|
||||
require.EqualError(t, err, `aur.private_key is empty`)
|
||||
require.Equal(t, "", result)
|
||||
})
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
pkgname='foo-bin'
|
||||
pkgver=1.0.1
|
||||
pkgrel=1
|
||||
pkgdesc='A run pipe test pkgbuild and FOO=foo_is_bar'
|
||||
pkgdesc='A run pipe test aur and FOO=foo_is_bar'
|
||||
url='https://github.com/goreleaser'
|
||||
arch=('aarch64' 'armv6h' 'armv7h' 'i686' 'x86_64')
|
||||
license=('MIT')
|
||||
|
@ -1,5 +1,5 @@
|
||||
pkgbase = foo-bin
|
||||
pkgdesc = A run pipe test pkgbuild and FOO=foo_is_bar
|
||||
pkgdesc = A run pipe test aur and FOO=foo_is_bar
|
||||
pkgver = 1.0.1
|
||||
pkgrel = 1
|
||||
url = https://github.com/goreleaser
|
||||
|
@ -24,7 +24,7 @@ type releasePackage struct {
|
||||
Arch string
|
||||
}
|
||||
|
||||
const pkgBuildTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
|
||||
const aurTemplateData = `# This file was generated by GoReleaser. DO NOT EDIT.
|
||||
|
||||
{{- range .Maintainers }}
|
||||
# Maintainer: {{ . }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user