aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/scripts/postpublish.js
blob: c2dffa920c51b651efceff2c5542a0588ec8e947 (plain) (blame)
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
const execAsync = require('async-child-process').execAsync;
const semverSort = require('semver-sort');

const packagePrefix = '0x.js@';
const gitTagsCommand = 'git tags -l "' + packagePrefix + '*"';
let latestTag;
execAsync(gitTagsCommand)
    .then(function(result) {
        if (result.stderr !== '') {
            throw new Error(result.stderr);
        }
        const tags = result.stdout.trim().split('\n');
        const versions = tags.map(function(tag) {
            return tag.slice(packagePrefix.length);
        });
        const sortedVersions = semverSort.desc(versions);
        latestTag = packagePrefix + sortedVersions[0];
        return execAsync('LATEST_TAG=' + latestTag + ' yarn release');
    })
    .then(function(result) {
        if (result.stderr !== '') {
            throw new Error(result.stderr);
        }
        return execAsync('yarn docs:json');        
    })
    .then(function(result) {
        if (result.stderr !== '') {
            throw new Error(result.stderr);
        }
        const s3Url = 's3://0xjs-docs-jsons/v' + latestTag +'.json';
        return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json');  
    });