mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-13 13:48:40 +02:00
fix: support multiple binaries in scoop pipe (#909)
* fix: support multiple binaries in scoop pipe * fix: lint
This commit is contained in:
parent
850205abf1
commit
23df4b562c
@ -109,9 +109,9 @@ type Manifest struct {
|
|||||||
|
|
||||||
// Resource represents a combination of a url and a binary name for an architecture
|
// Resource represents a combination of a url and a binary name for an architecture
|
||||||
type Resource struct {
|
type Resource struct {
|
||||||
URL string `json:"url"` // URL to the archive
|
URL string `json:"url"` // URL to the archive
|
||||||
Bin string `json:"bin"` // name of binary inside the archive
|
Bin []string `json:"bin"` // name of binary inside the archive
|
||||||
Hash string `json:"hash"` // the archive checksum
|
Hash string `json:"hash"` // the archive checksum
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.Buffer, error) {
|
func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.Buffer, error) {
|
||||||
@ -145,7 +145,7 @@ func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.B
|
|||||||
|
|
||||||
manifest.Architecture[arch] = Resource{
|
manifest.Architecture[arch] = Resource{
|
||||||
URL: url,
|
URL: url,
|
||||||
Bin: ctx.Config.Builds[0].Binary + ".exe", // TODO: this is wrong
|
Bin: binaries(artifact),
|
||||||
Hash: sum,
|
Hash: sum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,3 +157,12 @@ func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.B
|
|||||||
_, err = result.Write(data)
|
_, err = result.Write(data)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func binaries(a artifact.Artifact) []string {
|
||||||
|
// nolint: prealloc
|
||||||
|
var bins []string
|
||||||
|
for _, b := range a.ExtraOr("Builds", []artifact.Artifact{}).([]artifact.Artifact) {
|
||||||
|
bins = append(bins, b.ExtraOr("Binary", "").(string)+".exe")
|
||||||
|
}
|
||||||
|
return bins
|
||||||
|
}
|
||||||
|
@ -5,9 +5,8 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||||
"github.com/goreleaser/goreleaser/internal/client"
|
"github.com/goreleaser/goreleaser/internal/client"
|
||||||
@ -403,9 +402,6 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
GitHubURLs: config.GitHubURLs{
|
GitHubURLs: config.GitHubURLs{
|
||||||
Download: "https://github.com",
|
Download: "https://github.com",
|
||||||
},
|
},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
Dist: ".",
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archive: config.Archive{
|
Archive: config.Archive{
|
||||||
@ -471,21 +467,61 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
var ctx = tt.ctx
|
t.Run(tt.filename, func(t *testing.T) {
|
||||||
Pipe{}.Default(ctx)
|
var ctx = tt.ctx
|
||||||
out, err := buildManifest(ctx, []artifact.Artifact{
|
Pipe{}.Default(ctx)
|
||||||
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
|
out, err := buildManifest(ctx, []artifact.Artifact{
|
||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{
|
||||||
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
||||||
|
Goos: "windows",
|
||||||
|
Goarch: "amd64",
|
||||||
|
Path: file,
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Builds": []artifact.Artifact{
|
||||||
|
{
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Binary": "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Binary": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "foo_1.0.1_windows_386.tar.gz",
|
||||||
|
Goos: "windows",
|
||||||
|
Goarch: "386",
|
||||||
|
Path: file,
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Builds": []artifact.Artifact{
|
||||||
|
{
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Binary": "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Extra: map[string]interface{}{
|
||||||
|
"Binary": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if *update {
|
||||||
|
require.NoError(t, ioutil.WriteFile(tt.filename, out.Bytes(), 0655))
|
||||||
|
}
|
||||||
|
bts, err := ioutil.ReadFile(tt.filename)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, string(bts), out.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
if *update {
|
|
||||||
require.NoError(t, ioutil.WriteFile(tt.filename, out.Bytes(), 0655))
|
|
||||||
}
|
|
||||||
bts, err := ioutil.ReadFile(tt.filename)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.Equal(t, string(bts), out.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
"architecture": {
|
"architecture": {
|
||||||
"32bit": {
|
"32bit": {
|
||||||
"url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_386.tar.gz",
|
"url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_386.tar.gz",
|
||||||
"bin": "test.exe",
|
"bin": [
|
||||||
|
"foo.exe",
|
||||||
|
"bar.exe"
|
||||||
|
],
|
||||||
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
||||||
},
|
},
|
||||||
"64bit": {
|
"64bit": {
|
||||||
"url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_amd64.tar.gz",
|
"url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_amd64.tar.gz",
|
||||||
"bin": "test.exe",
|
"bin": [
|
||||||
|
"foo.exe",
|
||||||
|
"bar.exe"
|
||||||
|
],
|
||||||
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
"architecture": {
|
"architecture": {
|
||||||
"32bit": {
|
"32bit": {
|
||||||
"url": "http://github.mycompany.com/foo/bar/v1.0.1/foo_1.0.1_windows_386.tar.gz",
|
"url": "http://github.mycompany.com/foo/bar/v1.0.1/foo_1.0.1_windows_386.tar.gz",
|
||||||
"bin": "test.exe",
|
"bin": [
|
||||||
|
"foo.exe",
|
||||||
|
"bar.exe"
|
||||||
|
],
|
||||||
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
||||||
},
|
},
|
||||||
"64bit": {
|
"64bit": {
|
||||||
"url": "http://github.mycompany.com/foo/bar/v1.0.1/foo_1.0.1_windows_amd64.tar.gz",
|
"url": "http://github.mycompany.com/foo/bar/v1.0.1/foo_1.0.1_windows_amd64.tar.gz",
|
||||||
"bin": "test.exe",
|
"bin": [
|
||||||
|
"foo.exe",
|
||||||
|
"bar.exe"
|
||||||
|
],
|
||||||
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
"hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user