electron-updater-example icon indicating copy to clipboard operation
electron-updater-example copied to clipboard

Example for S3 provider instead of github

Open dede-plato opened this issue 7 years ago • 2 comments

Hi, I am looking for the example of s3 provider for auto-update. I've already done s3 publishing. But can't check the update from s3. Is there any example that I can follow for the window? Thanks.

dede-plato avatar Jun 26 '18 07:06 dede-plato

@dede-plato I have no experience with S3 (and very little with Windows). But to whoever knows how to do it, feel free to post here.

iffy avatar Jun 26 '18 16:06 iffy

I did it for macOS, but I would assume, it is the same for Windows.

With the electron-builder one has the use the S3Options. (Here is the JSON scheme for S3 if you prefer that.)

{
...  
"build": {
    ...
    "publish": [
      {
        "provider": "s3",
        "bucket": "your-bucket-name",
        "path": "optional/download/path"
      }
    ],
    ...
  },
...
}

Assuming your S3 is public, you can omit the acl prop, it falls back to "public-read". If your bucket is private, see this or this threads.

You also have to tune the ACL config on S3, I ended up with this policy file based on this and this comments.

{
  "Statement": [
    {
      "Sid": "yourId1",
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:GetBucketLocation",
        "s3:ListBucketMultipartUploads"
      ],
      "Resource": "arn:aws:s3:::your-bucket-name"
    },
    {
      "Sid": "yourId2",
      "Effect": "Allow",
      "Action": [
        "s3:AbortMultipartUpload",
        "s3:GetObject",
        "s3:GetObjectAcl",
        "s3:GetObjectVersion",
        "s3:ListMultipartUploadParts",
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Resource": "arn:aws:s3:::your-bucket-name/optional/download/path/*"
    }
  ],
  "Version": "2012-10-17"
}

Notes:

  • You can explicitly set the acl prop to null,
  • People say it is better to use a secret env variable for the bucket name, instead of writing it into the electron builder config (YAML, or package.json). I could not achieve it.

I hope this helps others configuring the electron updated with S3.

PS: If you have spotted any mistakes/anti-patterns in my config, let me know. Thanks!

kittaakos avatar May 20 '20 14:05 kittaakos