From 8e8aa1d2cb0a635bedf1bc1ff9d99fb7208d99c1 Mon Sep 17 00:00:00 2001 From: Ralph Meier Date: Wed, 23 Aug 2017 10:19:27 +0200 Subject: [PATCH] feat: only allow patch releases in a maintenance branch --- bin/semantic-release.sh | 9 ++++++++- js/semantic-release/verifyPatchRelease.js | 18 ++++++++++++++++++ package.json | 3 --- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 js/semantic-release/verifyPatchRelease.js diff --git a/bin/semantic-release.sh b/bin/semantic-release.sh index f7ad95c..f31d0ac 100755 --- a/bin/semantic-release.sh +++ b/bin/semantic-release.sh @@ -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 diff --git a/js/semantic-release/verifyPatchRelease.js b/js/semantic-release/verifyPatchRelease.js new file mode 100644 index 0000000..68ba006 --- /dev/null +++ b/js/semantic-release/verifyPatchRelease.js @@ -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.` + )); +}; diff --git a/package.json b/package.json index 1bdbe04..15de7c4 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,5 @@ "semver": "^5.3.0", "tap-spec": "^4.1.1", "tape": "^4.8.0" - }, - "release": { - "verifyConditions": "@semantic-release/condition-travis" } }