You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat(source): add prefix_template option (#2620)
This commit is contained in:
@@ -31,7 +31,19 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
|||||||
filename := name + "." + ctx.Config.Source.Format
|
filename := name + "." + ctx.Config.Source.Format
|
||||||
path := filepath.Join(ctx.Config.Dist, filename)
|
path := filepath.Join(ctx.Config.Dist, filename)
|
||||||
log.WithField("file", filename).Info("creating source archive")
|
log.WithField("file", filename).Info("creating source archive")
|
||||||
out, err := git.Clean(git.Run("archive", "-o", path, ctx.Git.FullCommit))
|
args := []string{
|
||||||
|
"archive",
|
||||||
|
"-o", path,
|
||||||
|
}
|
||||||
|
if ctx.Config.Source.PrefixTemplate != "" {
|
||||||
|
prefix, err := tmpl.New(ctx).Apply(ctx.Config.Source.PrefixTemplate)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, "--prefix", prefix)
|
||||||
|
}
|
||||||
|
args = append(args, ctx.Git.FullCommit)
|
||||||
|
out, err := git.Clean(git.Run(args...))
|
||||||
log.Debug(out)
|
log.Debug(out)
|
||||||
ctx.Artifacts.Add(&artifact.Artifact{
|
ctx.Artifacts.Add(&artifact.Artifact{
|
||||||
Type: artifact.UploadableSourceArchive,
|
Type: artifact.UploadableSourceArchive,
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ func TestArchive(t *testing.T) {
|
|||||||
ProjectName: "foo",
|
ProjectName: "foo",
|
||||||
Dist: "dist",
|
Dist: "dist",
|
||||||
Source: config.Source{
|
Source: config.Source{
|
||||||
Format: format,
|
Format: format,
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
|
PrefixTemplate: "{{ .ProjectName }}-{{ .Version }}/",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
ctx.Git.FullCommit = "HEAD"
|
ctx.Git.FullCommit = "HEAD"
|
||||||
|
|||||||
@@ -756,9 +756,10 @@ type Publisher struct {
|
|||||||
|
|
||||||
// Source configuration.
|
// Source configuration.
|
||||||
type Source struct {
|
type Source struct {
|
||||||
NameTemplate string `yaml:"name_template,omitempty"`
|
NameTemplate string `yaml:"name_template,omitempty"`
|
||||||
Format string `yaml:"format,omitempty"`
|
Format string `yaml:"format,omitempty"`
|
||||||
Enabled bool `yaml:"enabled,omitempty"`
|
Enabled bool `yaml:"enabled,omitempty"`
|
||||||
|
PrefixTemplate string `yaml:"prefix_template,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project includes all project configuration.
|
// Project includes all project configuration.
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ source:
|
|||||||
# Any format git-archive supports, this supports too.
|
# Any format git-archive supports, this supports too.
|
||||||
# Defaults to `tar.gz`
|
# Defaults to `tar.gz`
|
||||||
format: 'tar'
|
format: 'tar'
|
||||||
|
|
||||||
|
# Prefix template.
|
||||||
|
# String to prepend to each filename in the archive.
|
||||||
|
# Defaults to empty
|
||||||
|
prefix_template: '{{ .ProjectName }}-{{ .Version }}/'
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! tip
|
!!! tip
|
||||||
|
|||||||
Reference in New Issue
Block a user