From 2eaeba8ba8c2a13cee7c53dc9b2ee3e6b65c77e5 Mon Sep 17 00:00:00 2001 From: Rishabh Garg Date: Sun, 20 Oct 2019 12:05:13 +0530 Subject: [PATCH] Updated current version and previous version logic (#554) no issue - Use current version from `package.json` instead of `npm_package_version` env variable - Use `release.tag_name` instead of `release.name` for previous version --- gulpfile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index eec4d12..e19cbf7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,7 @@ const postcss = require('gulp-postcss'); const zip = require('gulp-zip'); const uglify = require('gulp-uglify'); const beeper = require('beeper'); +const fs = require('fs'); // postcss plugins const autoprefixer = require('autoprefixer'); @@ -130,9 +131,9 @@ const previousRelease = () => { console.log('No releases found. Skipping'); return; } - - console.log(`Previous version ${response[0].name}`); - return response[0].name; + let prevVersion = response[0].tag_name || response[0].name; + console.log(`Previous version ${prevVersion}`); + return prevVersion; }); }; @@ -152,7 +153,9 @@ const previousRelease = () => { */ const release = () => { // @NOTE: https://yarnpkg.com/lang/en/docs/cli/version/ - const newVersion = process.env.npm_package_version; + // require(./package.json) can run into caching issues, this re-reads from file everytime on release + var packageJSON = JSON.parse(fs.readFileSync('./package.json')); + const newVersion = packageJSON.version; let shipsWithGhost = '{version}'; let compatibleWithGhost = '2.10.0'; const ghostEnvValues = process.env.GHOST || null;