Skip to content

Commit

Permalink
feat: only allow patch releases in a maintenance branch
Browse files Browse the repository at this point in the history
  • Loading branch information
DaRaFF committed Aug 23, 2017
1 parent f9ef3b8 commit 8e8aa1d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
9 changes: 8 additions & 1 deletion bin/semantic-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
set -e

# Set new version
semantic-release pre
if [[ $TRAVIS_PULL_REQUEST =~ false ]]; then
if [[ $TRAVIS_BRANCH =~ ^maintenance- ]]; then
# only allow patch releases in a maintenance branch
semantic-release pre --verify-release="./js/semantic-release/verifyPatchRelease.js"
else
semantic-release pre
fi
fi

# Remove all devDeps so shrinkwrap does not pick them up.
# Shrinkwrap shouldn't pick up devDeps, but there is a bug so it picks up the
Expand Down
18 changes: 18 additions & 0 deletions js/semantic-release/verifyPatchRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const SRError = require('@semantic-release/error');

module.exports = (pluginConfig, config, cb) => {
const type = config.nextRelease.type;

// Only allow a patch or initial release
if (type === 'patch' || type === 'initial') {
cb(null);
return;
}

cb(new SRError(
`a 'minor' or a 'major' release is not allowed in a maintenance branch.\n` +
`Please update your commit messages in the maintenance branch.`
));
};
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@
"semver": "^5.3.0",
"tap-spec": "^4.1.1",
"tape": "^4.8.0"
},
"release": {
"verifyConditions": "@semantic-release/condition-travis"
}
}

0 comments on commit 8e8aa1d

Please sign in to comment.