diff --git a/gulpfile.js b/gulpfile.js index 2d4d4000..00d8a921 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,20 @@ function genNpmPluginXML() { fs.writeFileSync('plugin.xml', xml); }; +// first match only! +var PLUGIN_XML_VERSION_REGEX = /^\s*version=\"[\d\.]*\"\>$/m; +gulp.task('update-plugin-xml-version', () => { + var versionNumber = require('./package.json').version; + // this will break if plugin.xml is not formatted exactly as we expect + // so you might end up needing to fix the regex + for (target of [ '.xml', '.template.xml' ]) { + var pluginXML = fs.readFileSync('plugin' + target, 'utf8'); + var newVersionXML = ` version="${versionNumber}">`; + pluginXML = pluginXML.replace(PLUGIN_XML_VERSION_REGEX, newVersionXML); + fs.writeFileSync('plugin' + target, pluginXML); + } +}); // generate plugin.xml for local development // here we reference the frameworks instead of all the files directly function getDevPluginXML() { diff --git a/package.json b/package.json index 46984bda..c30fa6a7 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "license": "MIT", "scripts": { "prerelease": "gulp prerelease", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", + "semantic-release": "semantic-release pre && gulp update-plugin-xml-version && npm publish && semantic-release post", "commit": "git-cz" }, "dependencies": {