This commit is contained in:
Alex Gyoshev 2017-05-10 16:17:10 +03:00
Родитель 35dc1190bf
Коммит d248eed29b
5 изменённых файлов: 71 добавлений и 1 удалений

Просмотреть файл

@ -28,4 +28,4 @@ after_success:
- npm run semantic-release
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"
- "/^v\\d+\\.\\d+\\.\\d+(\\-.*)?$/"

Просмотреть файл

@ -0,0 +1,25 @@
const analyzeCommits = require('@semantic-release/commit-analyzer')
module.exports = function (pluginConfig, config, cb) {
// run standard commit analysis
return analyzeCommits(pluginConfig, config, function(error, type) {
const branch = config.env.TRAVIS_BRANCH;
const distTag = config.options.branchTags[branch];
let releaseType = type;
// if branch publishes a dist-tag
if (type && distTag) {
// map all types of releases to prereleases
releaseType = {
'major': 'premajor',
'minor': 'preminor',
'patch': 'prepatch'
}[type] || type;
console.log("Publishing a " + releaseType + " release.");
}
cb(error, releaseType);
});
};

Просмотреть файл

@ -0,0 +1,19 @@
const conditionTravis = require('@semantic-release/condition-travis');
module.exports = function (pluginConfig, config, cb) {
const branch = config.env.TRAVIS_BRANCH;
const distTag = config.options.branchTags[branch];
// update semantic-release configuration to publish:
// - from this branch
// - with the specified dist tag
if (distTag) {
console.log(`Enable prerelease on dist-tag '${distTag}'.`);
config.options.branch = branch;
config.npm.tag = distTag;
}
// run default travis checks with the new configuration
return conditionTravis(pluginConfig, config, cb);
};

15
build/sr-verifyRelease.js Normal file
Просмотреть файл

@ -0,0 +1,15 @@
module.exports = function (pluginConfig, config, cb) {
if (config.nextRelease) {
// change version suffix of pre-releases from '-number' to '-tag.timestamp'
const now = new Date();
const timestamp = now.toISOString().replace(/[\-T\:]/g, "").slice(0,12);
const suffix = `-${config.npm.tag}.${timestamp}`;
const release = config.nextRelease;
release.version = release.version.replace(/\-.+$/, suffix);
console.log(`Ready for release v${release.version}`);
}
cb(null);
};

Просмотреть файл

@ -16,6 +16,17 @@
"publishConfig": {
"registry": "https://registry.npm.telerik.com"
},
"release": {
"branchTags": {
"develop": "dev"
},
"fallbackTags": {
"dev": "latest"
},
"verifyConditions": "./build/sr-verifyConditions",
"analyzeCommits": "./build/sr-analyzeCommits",
"verifyRelease": "./build/sr-verifyRelease"
},
"scripts": {
"lint": "sass-lint -v -c ./sass-lint.yml",
"api": "sassdoc ./scss/",