Skip to content
Permalink
Browse files

feat: support profiles on aws s3

  • Loading branch information...
caarlos0 committed May 13, 2018
1 parent 56d87ae commit 0b25773b773d75494e4b4213d919a9bed75ae8c5
Showing with 20 additions and 2 deletions.
  1. +1 −0 config/config.go
  2. +6 −0 pipeline/s3/s3.go
  3. +13 −2 www/content/s3.md
@@ -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

0 comments on commit 0b25773

Please sign in to comment.
You can’t perform that action at this time.