From 5277d4a2666a795d01b7d3d4d018ca6d0e42399f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 17 Nov 2017 14:09:48 -0600 Subject: Move most of code for getting latest tag/version and calling publish_release to postpublish_utils script in top-level dir --- scripts/postpublish_utils.js | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/postpublish_utils.js (limited to 'scripts') diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js new file mode 100644 index 000000000..6b7be4f0e --- /dev/null +++ b/scripts/postpublish_utils.js @@ -0,0 +1,47 @@ +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 tags -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, + }); + }, +}; -- cgit v1.2.3 From 7f595169c1bc02873d47a5b7411dfb7414c19041 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 17 Nov 2017 16:44:56 -0600 Subject: Put release name generation into postpublish_utils --- scripts/postpublish_utils.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts') diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index 6b7be4f0e..4c9882fa8 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -44,4 +44,7 @@ module.exports = { assets: assets, }); }, + getReleaseName(subPackageName, version) { + const releaseName = subPackageName + ' v' + version; + }, }; -- cgit v1.2.3 From 37a9b64503edc8fe750dad02a7a45d8303f9ba04 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 17 Nov 2017 17:00:15 -0600 Subject: Small fixes --- scripts/postpublish_utils.js | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index 4c9882fa8..3fb079bad 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -46,5 +46,6 @@ module.exports = { }, getReleaseName(subPackageName, version) { const releaseName = subPackageName + ' v' + version; + return releaseName; }, }; -- cgit v1.2.3 From e3cc2834789ec5d4affceee2d03015085b24d907 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 21 Nov 2017 13:43:39 -0600 Subject: Fix a typo in postpublish utils tags -> tag --- scripts/postpublish_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index 3fb079bad..4f9798e60 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -9,7 +9,7 @@ const githubPersonalAccessToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS module.exports = { getLatestTagAndVersionAsync: function(subPackageName) { const subPackagePrefix = subPackageName + '@'; - const gitTagsCommand = 'git tags -l "' + subPackagePrefix + '*"'; + const gitTagsCommand = 'git tag -l "' + subPackagePrefix + '*"'; return execAsync(gitTagsCommand) .then(function(result) { if (result.stderr !== '') { -- cgit v1.2.3