Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: calculate version number from packge.json and stick it into plugin.xml on semantic release #240

Merged
merged 2 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down