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
|
||||
path := filepath.Join(ctx.Config.Dist, filename)
|
||||
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)
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.UploadableSourceArchive,
|
||||
|
||||
@@ -30,6 +30,7 @@ func TestArchive(t *testing.T) {
|
||||
Source: config.Source{
|
||||
Format: format,
|
||||
Enabled: true,
|
||||
PrefixTemplate: "{{ .ProjectName }}-{{ .Version }}/",
|
||||
},
|
||||
})
|
||||
ctx.Git.FullCommit = "HEAD"
|
||||
|
||||
@@ -759,6 +759,7 @@ type Source struct {
|
||||
NameTemplate string `yaml:"name_template,omitempty"`
|
||||
Format string `yaml:"format,omitempty"`
|
||||
Enabled bool `yaml:"enabled,omitempty"`
|
||||
PrefixTemplate string `yaml:"prefix_template,omitempty"`
|
||||
}
|
||||
|
||||
// Project includes all project configuration.
|
||||
|
||||
@@ -18,6 +18,11 @@ source:
|
||||
# Any format git-archive supports, this supports too.
|
||||
# Defaults to `tar.gz`
|
||||
format: 'tar'
|
||||
|
||||
# Prefix template.
|
||||
# String to prepend to each filename in the archive.
|
||||
# Defaults to empty
|
||||
prefix_template: '{{ .ProjectName }}-{{ .Version }}/'
|
||||
```
|
||||
|
||||
!!! tip
|
||||
|
||||
Reference in New Issue
Block a user