diff --git a/config/config.go b/config/config.go index bcc6ff60e..f2d8bbc3b 100644 --- a/config/config.go +++ b/config/config.go @@ -249,6 +249,7 @@ type S3 struct { Region string Bucket string Folder string + Profile string Endpoint string // used for minio for example } diff --git a/pipeline/s3/s3.go b/pipeline/s3/s3.go index e11146773..b089e17b1 100644 --- a/pipeline/s3/s3.go +++ b/pipeline/s3/s3.go @@ -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), diff --git a/www/content/s3.md b/www/content/s3.md index e2c8e32af..accc10013 100644 --- a/www/content/s3.md +++ b/www/content/s3.md @@ -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