mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-31 01:53:50 +02:00
fix: templates in release URLs (#3365)
closes #3356 Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
5185b5b6ed
commit
2244bba1e0
@ -28,15 +28,14 @@ func setupGitHub(ctx *context.Context) error {
|
||||
}
|
||||
ctx.Config.Release.GitHub.Name = name
|
||||
|
||||
ctx.ReleaseURL = fmt.Sprintf(
|
||||
ctx.ReleaseURL, err = tmpl.New(ctx).Apply(fmt.Sprintf(
|
||||
"%s/%s/%s/releases/tag/%s",
|
||||
ctx.Config.GitHubURLs.Download,
|
||||
ctx.Config.Release.GitHub.Owner,
|
||||
ctx.Config.Release.GitHub.Name,
|
||||
ctx.Git.CurrentTag,
|
||||
)
|
||||
|
||||
return nil
|
||||
))
|
||||
return err
|
||||
}
|
||||
|
||||
func setupGitLab(ctx *context.Context) error {
|
||||
@ -60,15 +59,14 @@ func setupGitLab(ctx *context.Context) error {
|
||||
}
|
||||
ctx.Config.Release.GitLab.Name = name
|
||||
|
||||
ctx.ReleaseURL = fmt.Sprintf(
|
||||
ctx.ReleaseURL, err = tmpl.New(ctx).Apply(fmt.Sprintf(
|
||||
"%s/%s/%s/-/releases/%s",
|
||||
ctx.Config.GitLabURLs.Download,
|
||||
ctx.Config.Release.GitLab.Owner,
|
||||
ctx.Config.Release.GitLab.Name,
|
||||
ctx.Git.CurrentTag,
|
||||
)
|
||||
|
||||
return nil
|
||||
))
|
||||
return err
|
||||
}
|
||||
|
||||
func setupGitea(ctx *context.Context) error {
|
||||
@ -92,13 +90,12 @@ func setupGitea(ctx *context.Context) error {
|
||||
}
|
||||
ctx.Config.Release.Gitea.Name = name
|
||||
|
||||
ctx.ReleaseURL = fmt.Sprintf(
|
||||
ctx.ReleaseURL, err = tmpl.New(ctx).Apply(fmt.Sprintf(
|
||||
"%s/%s/%s/releases/tag/%s",
|
||||
ctx.Config.GiteaURLs.Download,
|
||||
ctx.Config.Release.Gitea.Owner,
|
||||
ctx.Config.Release.Gitea.Name,
|
||||
ctx.Git.CurrentTag,
|
||||
)
|
||||
|
||||
return nil
|
||||
))
|
||||
return err
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ func TestSetupGitLab(t *testing.T) {
|
||||
t.Run("with templates", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{
|
||||
Env: []string{"NAME=foo", "OWNER=bar"},
|
||||
GitLabURLs: config.GitLabURLs{
|
||||
Download: "https://{{ .Env.OWNER }}/download",
|
||||
},
|
||||
Release: config.Release{
|
||||
GitLab: config.Repo{
|
||||
Owner: "{{.Env.OWNER}}",
|
||||
@ -31,6 +34,7 @@ func TestSetupGitLab(t *testing.T) {
|
||||
require.NoError(t, setupGitLab(ctx))
|
||||
require.Equal(t, "bar", ctx.Config.Release.GitLab.Owner)
|
||||
require.Equal(t, "foo", ctx.Config.Release.GitLab.Name)
|
||||
require.Equal(t, "https://bar/download/bar/foo/-/releases/", ctx.ReleaseURL)
|
||||
})
|
||||
|
||||
t.Run("with invalid templates", func(t *testing.T) {
|
||||
@ -73,6 +77,9 @@ func TestSetupGitea(t *testing.T) {
|
||||
t.Run("with templates", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{
|
||||
Env: []string{"NAME=foo", "OWNER=bar"},
|
||||
GiteaURLs: config.GiteaURLs{
|
||||
Download: "https://{{ .Env.OWNER }}/download",
|
||||
},
|
||||
Release: config.Release{
|
||||
Gitea: config.Repo{
|
||||
Owner: "{{.Env.OWNER}}",
|
||||
@ -84,6 +91,7 @@ func TestSetupGitea(t *testing.T) {
|
||||
require.NoError(t, setupGitea(ctx))
|
||||
require.Equal(t, "bar", ctx.Config.Release.Gitea.Owner)
|
||||
require.Equal(t, "foo", ctx.Config.Release.Gitea.Name)
|
||||
require.Equal(t, "https://bar/download/bar/foo/releases/tag/", ctx.ReleaseURL)
|
||||
})
|
||||
|
||||
t.Run("with invalid templates", func(t *testing.T) {
|
||||
@ -126,6 +134,9 @@ func TestSetupGitHub(t *testing.T) {
|
||||
t.Run("with templates", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{
|
||||
Env: []string{"NAME=foo", "OWNER=bar"},
|
||||
GitHubURLs: config.GitHubURLs{
|
||||
Download: "https://{{ .Env.OWNER }}/download",
|
||||
},
|
||||
Release: config.Release{
|
||||
GitHub: config.Repo{
|
||||
Owner: "{{.Env.OWNER}}",
|
||||
@ -137,6 +148,7 @@ func TestSetupGitHub(t *testing.T) {
|
||||
require.NoError(t, setupGitHub(ctx))
|
||||
require.Equal(t, "bar", ctx.Config.Release.GitHub.Owner)
|
||||
require.Equal(t, "foo", ctx.Config.Release.GitHub.Name)
|
||||
require.Equal(t, "https://bar/download/bar/foo/releases/tag/", ctx.ReleaseURL)
|
||||
})
|
||||
|
||||
t.Run("with invalid templates", func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user