mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-13 11:50:34 +02:00
feat: allow use template for s3 bucket
This commit is contained in:
parent
db7686fed0
commit
0aa80eca02
@ -71,6 +71,12 @@ func upload(ctx *context.Context, conf config.S3) error {
|
|||||||
svc := s3.New(sess, &aws.Config{
|
svc := s3.New(sess, &aws.Config{
|
||||||
Region: aws.String(conf.Region),
|
Region: aws.String(conf.Region),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bucket, err := tmpl.New(ctx).Apply(conf.Bucket)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
folder, err := tmpl.New(ctx).Apply(conf.Folder)
|
folder, err := tmpl.New(ctx).Apply(conf.Folder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -93,12 +99,12 @@ func upload(ctx *context.Context, conf config.S3) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"bucket": conf.Bucket,
|
"bucket": bucket,
|
||||||
"folder": folder,
|
"folder": folder,
|
||||||
"artifact": artifact.Name,
|
"artifact": artifact.Name,
|
||||||
}).Info("uploading")
|
}).Info("uploading")
|
||||||
_, err = svc.PutObjectWithContext(ctx, &s3.PutObjectInput{
|
_, err = svc.PutObjectWithContext(ctx, &s3.PutObjectInput{
|
||||||
Bucket: aws.String(conf.Bucket),
|
Bucket: aws.String(bucket),
|
||||||
Key: aws.String(filepath.Join(folder, artifact.Name)),
|
Key: aws.String(filepath.Join(folder, artifact.Name)),
|
||||||
Body: f,
|
Body: f,
|
||||||
ACL: aws.String(conf.ACL),
|
ACL: aws.String(conf.ACL),
|
||||||
|
@ -22,6 +22,7 @@ s3:
|
|||||||
# You can have multiple s3 configs
|
# You can have multiple s3 configs
|
||||||
-
|
-
|
||||||
# Bucket name (without the s3:// prefix)
|
# Bucket name (without the s3:// prefix)
|
||||||
|
# You can use `{{ .Env.BUCKET_ID }}`
|
||||||
# Default is empty.
|
# Default is empty.
|
||||||
bucket: my-bucket
|
bucket: my-bucket
|
||||||
# AWS Region to use.
|
# AWS Region to use.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user