-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
deploy.js
43 lines (37 loc) · 1.13 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable no-console */
// See https://github.com/Shopify/js-uploader
const {resolve} = require('path');
const Uploader = require('@shopify/js-uploader');
const {S3} = require('aws-sdk');
const semver = require('semver');
const awsConfig = require('../secrets.json').aws;
const currentVersion = require('../package.json').version;
// Check if the current version is stable
// and doesn’t include -alpha.x, -beta.x, -rc.x tags
const isStableVersion = !semver.prerelease(currentVersion);
const files = [
resolve(__dirname, '../build/polaris.css'),
resolve(__dirname, '../build/polaris.min.css'),
];
const awsS3 = new S3({
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
region: 'us-east-1',
params: {
Bucket: 'sdks.shopifycdn.com',
ACL: 'public-read',
},
});
const uploader = new Uploader({
files,
s3: awsS3,
destination: 'polaris',
version: currentVersion,
// Upload assets to the /latest/ directory
// only when the version is stable (no alpha, beta, rc…)
latest: isStableVersion,
});
uploader.deployStaticFiles().catch((err) => {
console.error(err);
process.exit(1);
});