mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: support profiles on aws s3
This commit is contained in:
parent
56d87ae699
commit
0b25773b77
@ -249,6 +249,7 @@ type S3 struct {
|
||||
Region string
|
||||
Bucket string
|
||||
Folder string
|
||||
Profile string
|
||||
Endpoint string // used for minio for example
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
@ -60,10 +61,15 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
func upload(ctx *context.Context, conf config.S3) error {
|
||||
var awsConfig = aws.NewConfig()
|
||||
// TODO: add a test for this
|
||||
if conf.Endpoint != "" {
|
||||
awsConfig.Endpoint = aws.String(conf.Endpoint)
|
||||
awsConfig.S3ForcePathStyle = aws.Bool(true)
|
||||
}
|
||||
// TODO: add a test for this
|
||||
if conf.Profile != "" {
|
||||
awsConfig.Credentials = credentials.NewSharedCredentials("", conf.Profile)
|
||||
}
|
||||
sess := session.Must(session.NewSession(awsConfig))
|
||||
svc := s3.New(sess, &aws.Config{
|
||||
Region: aws.String(conf.Region),
|
||||
|
@ -21,9 +21,11 @@ use cases. If you need one of such use cases, please open an issue/pull request.
|
||||
s3:
|
||||
# You can have multiple s3 configs
|
||||
-
|
||||
# bucket name
|
||||
# Bucket name (without the s3:// prefix)
|
||||
# Default is empty.
|
||||
bucket: my-bucket
|
||||
# region, defaults to us-east-1
|
||||
# AWS Region to use.
|
||||
# Defaults is us-east-1
|
||||
region: us-east-1
|
||||
# path inside the bucket.
|
||||
# This is parsed with the Go template engine and the following variables
|
||||
@ -35,8 +37,14 @@ s3:
|
||||
# string to insert a formated timestamp into the release name.
|
||||
# Default is `{{ .ProjectName }}/{{ .Tag }}`
|
||||
folder: "foo/bar/{{.Version}}"
|
||||
# Set a custom profile to use for this s3 config. If you have multiple
|
||||
# profiles setup in you ~/.aws config, this shall help defining which
|
||||
# profile to use in which s3 bucket.
|
||||
# Default is empty.
|
||||
profile: my-profile
|
||||
# Endpoint allows you to set a custom endpoint, which is useful if you
|
||||
# want to push your artifacts to a minio server for example.
|
||||
# Default is AWS S3 URL.
|
||||
endpoint: "http://minio.foo.com"
|
||||
```
|
||||
|
||||
@ -45,4 +53,7 @@ s3:
|
||||
GoReleaser will authenticate using the [same methods defined by aws-cli][auth].
|
||||
You can read the [docs][auth] to find out more about it.
|
||||
|
||||
You can also set diferent profile names for each S3 config, so you may be able
|
||||
to push to buckets in different accounts, for example.
|
||||
|
||||
[auth]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
|
||||
|
Loading…
x
Reference in New Issue
Block a user