aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJacob Evans <dekz@dekz.net>2017-11-23 11:37:34 +0800
committerGitHub <noreply@github.com>2017-11-23 11:37:34 +0800
commit437ac301db3c03c0abd0f741a17c56a4eebc2aa4 (patch)
tree2bd3276289578e99140f8f1168af58f07d566476 /scripts
parent9c9ce9752537122df51b935bf1f63f128414fc0f (diff)
parent215740fab27d75630f55e7a3194b9e498b511c08 (diff)
downloaddexon-0x-contracts-437ac301db3c03c0abd0f741a17c56a4eebc2aa4.tar.gz
dexon-0x-contracts-437ac301db3c03c0abd0f741a17c56a4eebc2aa4.tar.zst
dexon-0x-contracts-437ac301db3c03c0abd0f741a17c56a4eebc2aa4.zip
Merge branch 'development' into feature/calculate-remaining-proportions
Diffstat (limited to 'scripts')
-rw-r--r--scripts/postpublish_utils.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js
new file mode 100644
index 000000000..4f9798e60
--- /dev/null
+++ b/scripts/postpublish_utils.js
@@ -0,0 +1,51 @@
+const execAsync = require('async-child-process').execAsync;
+const semverSort = require('semver-sort');
+const promisify = require('es6-promisify');
+const publishRelease = require('publish-release');
+
+const publishReleaseAsync = promisify(publishRelease);
+const githubPersonalAccessToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS;
+
+module.exports = {
+ getLatestTagAndVersionAsync: function(subPackageName) {
+ const subPackagePrefix = subPackageName + '@';
+ const gitTagsCommand = 'git tag -l "' + subPackagePrefix + '*"';
+ return 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(subPackagePrefix.length);
+ });
+ const sortedVersions = semverSort.desc(versions);
+ const latestVersion = sortedVersions[0];
+ const latestTag = subPackagePrefix + latestVersion;
+ return {
+ tag: latestTag,
+ version: latestVersion
+ };
+ });
+ },
+ publishReleaseNotes: function(tag, releaseName, assets) {
+ console.log('POSTPUBLISH: Releasing ', releaseName, '...');
+ return publishReleaseAsync({
+ token: githubPersonalAccessToken,
+ owner: '0xProject',
+ repo: '0x.js',
+ tag: tag,
+ name: releaseName,
+ notes: 'TODO',
+ draft: false,
+ prerelease: false,
+ reuseRelease: true,
+ reuseDraftOnly: false,
+ assets: assets,
+ });
+ },
+ getReleaseName(subPackageName, version) {
+ const releaseName = subPackageName + ' v' + version;
+ return releaseName;
+ },
+};