source: app-deploy.js

Last change on this file was 1, checked in by Bart Vastenhouw, 5 years ago

First public release

File size: 1.4 KB
Line 
1// Load dependencies
2const fs = require('fs');
3const aws = require('aws-sdk');
4const Glob = require('glob');
5
6const spaces_endpoint = new aws.Endpoint('ams3.digitaloceanspaces.com');
7const s3 = new aws.S3({
8 endpoint: spaces_endpoint
9});
10
11const pkg_json = fs.readFileSync('package.json');
12let version = JSON.parse(pkg_json).version;
13
14const upload = (v, type) => {
15 let key = '';
16 if (type === '-mac.zip') {
17 key = `genius2-app-v${version}-mac.zip`;
18 }
19 if (type === '.AppImage') {
20 key = `genius2-app-v${version}-linux.AppImage`;
21 }
22 if (type === '.exe') {
23 key = `genius2-app-v${version}-setup-windows.exe`;
24 }
25 if (key.length === 0) return;
26
27 console.log('uploading', v, 'as', key);
28
29 fs.readFile(v, (err, data) => {
30 if (err) throw err;
31
32 const b64d = Buffer.from(data, 'binary');
33
34 const params = {
35 Bucket: 'erancihan',
36 ACL: 'public-read',
37 Body: b64d,
38 Key: `genius/v${version}/${key}`
39 };
40
41 s3.putObject(params, (err, data) => {
42 if (err) throw err;
43 console.log('success', key);
44 });
45 });
46};
47
48const mac_zips = new Glob(`${__dirname}/dist/*-mac.zip`, (e, f) => {
49 f.forEach(v => {
50 upload(v, '-mac.zip');
51 });
52});
53
54const linux_releases = new Glob(`${__dirname}/dist/*.AppImage`, (e, f) => {
55 f.forEach(v => {
56 upload(v, '.AppImage');
57 });
58});
59
60const win_exe = new Glob(`${__dirname}/dist/*.exe`, (e, f) => {
61 f.forEach(v => {
62 upload(v, '.exe');
63 });
64});
Note: See TracBrowser for help on using the repository browser.