Repository: electron-userland/electron-forge
Pull request #412 (2018-01-16 17:20:47)

Allow AWS credentials to be picked up from the environment or .aws/credentials file
* [x] I have read the [contribution documentation](https://github.com/electron-userland/electron-forge/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project follows, as appropriate.
* [x] The changes are appropriately documented (if applicable).
* [x] The changes have sufficient test coverage (if applicable).
* [x] The testsuite passes successfully on my local machine (if applicable).

**Summarize your changes:**

S3 publisher was failing to up the standard `.aws/credentials` file nor the standard `AWS_` env-vars. Instead it'd fail out early if you did not explicitly use the `package.json.config.s3` properties, which are preferred to env-vars/`credentials`.

May fix https://github.com/electron-userland/electron-forge/issues/259



Patch:
diff --git a/package.json b/package.json
index 5bb206da8..58c4d58c7 100644
--- a/package.json
+++ b/package.json
@@ -58,7 +58,7 @@
     "generate-changelog": "^1.0.2",
     "gulp": "^3.9.1",
     "gulp-babel": "^6.1.2",
-    "mocha": "^4.0.1",
+    "mocha": "^5.0.0",
     "nodemon": "^1.11.0",
     "nyc": "^11.0.0",
     "proxyquire": "^1.7.10",
@@ -106,6 +106,7 @@
     "cache": true
   },
   "dependencies": {
+    "@octokit/rest": "^14.0.4",
     "aws-sdk": "^2.9.0",
     "babel-register": "^6.16.3",
     "bluebird": "^3.4.6",
@@ -120,13 +121,13 @@
     "electron-packager": "^10.1.0",
     "electron-rebuild": "^1.6.0",
     "form-data": "^2.1.4",
-    "fs-extra": "^4.0.0",
-    "github": "^12.0.3",
+    "fs-extra": "^5.0.0",
     "glob": "^7.1.1",
-    "inquirer": "^4.0.0",
+    "inquirer": "^5.0.0",
     "lodash.merge": "^4.6.0",
     "lodash.template": "^4.4.0",
     "log-symbols": "^2.0.0",
+    "mime-types": "^2.1.17",
     "node-fetch": "^1.6.3",
     "node-gyp": "^3.4.0",
     "nugget": "^2.0.1",
@@ -152,7 +153,7 @@
     }
   },
   "optionalDependencies": {
-    "electron-installer-debian": "^0.7.1",
+    "electron-installer-debian": "^0.8.0",
     "electron-installer-dmg": "^0.2.0",
     "electron-installer-flatpak": "^0.8.0",
     "electron-installer-redhat": "^0.5.0",
diff --git a/src/makers/linux/deb.js b/src/makers/linux/deb.js
index dc314f3a3..854b275f7 100644
--- a/src/makers/linux/deb.js
+++ b/src/makers/linux/deb.js
@@ -1,5 +1,4 @@
 import path from 'path';
-import pify from 'pify';
 
 import { ensureFile } from '../../util/ensure-output';
 import isInstalled from '../../util/is-installed';
@@ -34,6 +33,6 @@ export default async ({ dir, targetArch, forgeConfig, packageJSON }) => {
     outPath,
   });
 
-  await pify(installer)(debianConfig);
+  await installer(debianConfig);
   return [outPath];
 };
diff --git a/src/publishers/github.js b/src/publishers/github.js
index c2eda8ae3..4c276e3dd 100644
--- a/src/publishers/github.js
+++ b/src/publishers/github.js
@@ -1,3 +1,5 @@
+import fs from 'fs-extra';
+import mime from 'mime-types';
 import path from 'path';
 
 import asyncOra from '../util/ora-handler';
@@ -57,10 +59,10 @@ export default async (artifacts, packageJSON, forgeConfig, authToken, tag) => {
           return done();
         }
         await github.getGitHub().repos.uploadAsset({
-          owner: forgeConfig.github_repository.owner,
-          repo: forgeConfig.github_repository.name,
-          id: release.id,
-          filePath: artifactPath,
+          url: release.upload_url,
+          file: fs.createReadStream(artifactPath),
+          contentType: mime.lookup(artifactPath) || 'application/octet-stream',
+          contentLength: (await fs.stat(artifactPath)).size,
           name: path.basename(artifactPath),
         });
         return done();
diff --git a/src/publishers/s3.js b/src/publishers/s3.js
index bc85abd98..46d2ee06d 100644
--- a/src/publishers/s3.js
+++ b/src/publishers/s3.js
@@ -15,18 +15,22 @@ AWS.util.update(AWS.S3.prototype, {
 
 export default async (artifacts, packageJSON, forgeConfig, authToken, tag) => {
   const s3Config = forgeConfig.s3;
+
   s3Config.secretAccessKey = s3Config.secretAccessKey || authToken;
-  if (!(s3Config.accessKeyId && s3Config.secretAccessKey && s3Config.bucket)) {
+
+  const s3Client = new AWS.S3({
+    accessKeyId: s3Config.accessKeyId,
+    secretAccessKey: s3Config.secretAccessKey,
+  });
+
+  if (!s3Client.config.credentials || !s3Config.bucket) {
     throw 'In order to publish to s3 you must set the "s3.accessKeyId", "process.env.ELECTRON_FORGE_S3_SECRET_ACCESS_KEY" and "s3.bucket" properties in your forge config. See the docs for more info'; // eslint-disable-line
   }
 
   d('creating s3 client with options:', s3Config);
 
   const client = s3.createClient({
-    s3Client: new AWS.S3({
-      accessKeyId: s3Config.accessKeyId || process.env.AWS_ACCESS_KEY_ID,
-      secretAccessKey: s3Config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY,
-    }),
+    s3Client,
   });
   client.s3.addExpect100Continue = () => {};
 
diff --git a/src/util/github.js b/src/util/github.js
index 65d808249..6ba7f8382 100644
--- a/src/util/github.js
+++ b/src/util/github.js
@@ -1,4 +1,4 @@
-import GitHubAPI from 'github';
+import GitHubAPI from '@octokit/rest';
 
 export default class GitHub {
   constructor(authToken, requireAuth) {


Test patch:
diff --git a/test/fast/github_spec.js b/test/fast/github_spec.js
index 67fa8b628..a2e5bd8c5 100644
--- a/test/fast/github_spec.js
+++ b/test/fast/github_spec.js
@@ -21,7 +21,7 @@ describe('GitHub', () => {
       }
     };
     GitHub = proxyquire.noCallThru().load('../../src/util/github', {
-      github: MockGitHub,
+      '@octokit/rest': MockGitHub,
     }).default;
   });
 
diff --git a/test/fast/makers/deb_spec.js b/test/fast/makers/deb_spec.js
index 8ef4c8a07..c2883caef 100644
--- a/test/fast/makers/deb_spec.js
+++ b/test/fast/makers/deb_spec.js
@@ -20,7 +20,7 @@ describe('deb maker', () => {
 
   beforeEach(() => {
     ensureFileStub = stub().returns(Promise.resolve());
-    eidStub = stub().callsArg(1);
+    eidStub = stub().resolves();
     forgeConfig = { electronInstallerDebian: {} };
 
     debModule = proxyquire.noPreserveCache().noCallThru().load('../../../src/makers/linux/deb', {