1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix(scoop): allow templating name and skip_upload

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-05-19 14:25:39 +00:00
parent dfcd535e31
commit 27f94523c8
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 34 additions and 8 deletions

View File

@ -143,7 +143,23 @@ func doRun(ctx *context.Context, scoop config.Scoop, cl client.ReleaserURLTempla
return ErrIncorrectArchiveCount{scoop.Goamd64, scoop.IDs, archives}
}
filename := scoop.Name + ".json"
name, err := tmpl.New(ctx).Apply(scoop.Name)
if err != nil {
return err
}
scoop.Name = name
ref, err := client.TemplateRef(tmpl.New(ctx).Apply, scoop.Bucket)
if err != nil {
return err
}
scoop.Bucket = ref
skipUpload, err := tmpl.New(ctx).Apply(scoop.SkipUpload)
if err != nil {
return err
}
scoop.SkipUpload = skipUpload
data, err := dataFor(ctx, scoop, cl, archives)
if err != nil {
@ -154,6 +170,7 @@ func doRun(ctx *context.Context, scoop config.Scoop, cl client.ReleaserURLTempla
return err
}
filename := scoop.Name + ".json"
path := filepath.Join(ctx.Config.Dist, filename)
log.WithField("manifest", path).Info("writing")
if err := os.WriteFile(path, content.Bytes(), 0o644); err != nil {
@ -225,12 +242,6 @@ func doPublish(ctx *context.Context, manifest *artifact.Artifact, cl client.Clie
return err
}
ref, err := client.TemplateRef(tmpl.New(ctx).Apply, scoop.Bucket)
if err != nil {
return err
}
scoop.Bucket = ref
repo := client.RepoFromRef(scoop.Bucket)
gpath := path.Join(scoop.Folder, manifest.Name)

View File

@ -591,8 +591,8 @@ func Test_doRun(t *testing.T) {
[]artifact.Artifact{
{Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
},
shouldNotErr,
testlib.RequireTemplateError,
shouldNotErr,
noAssertions,
},
{

View File

@ -11,6 +11,12 @@ commented example below:
# Since: v1.18
scoops:
-
# Name of the recipe
#
# Default: ProjectName
# Templates: allowed (since v1.19)
name: myproject
# URL which is determined by the given Token (github or gitlab)
#
# Default:
@ -40,6 +46,8 @@ scoops:
# Optionally a token can be provided, if it differs from the token provided
# to GoReleaser
#
# Templates: allowed
token: "{{ .Env.SCOOP_TAP_GITHUB_TOKEN }}"
# Sets up pull request creation instead of just pushing to the given branch.
@ -64,6 +72,8 @@ scoops:
# Since: v1.18
git:
# The Git URL to push.
#
# Templates: allowed
url: 'ssh://git@myserver.com:repo.git'
# The SSH private key that should be used to commit to the Git
@ -73,6 +83,8 @@ scoops:
# IMPORTANT: the key must not be password-protected.
#
# WARNING: do not expose your private key in the configuration file!
#
# Templates: allowed
private_key: '{{ .Env.PRIVATE_KEY_PATH }}'
# The value to be passed to `GIT_SSH_COMMAND`.
@ -80,6 +92,7 @@ scoops:
# to the Git URL.
#
# Default: 'ssh -i {{ .KeyPath }} -o StrictHostKeyChecking=accept-new -F /dev/null'
# Templates: allowed
ssh_command: 'ssh -i {{ .Env.KEY }} -o SomeOption=yes'
# Folder inside the repository to put the scoop.
@ -113,6 +126,8 @@ scoops:
# manifest leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the scoop bucket
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
#
# Templates: allowed (since v1.19)
skip_upload: true
# Persist data between application updates