Skip to content
Snippets Groups Projects
Commit 0c743143 authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

Merge branch 'fix/ci-semantic-release' into 'dev'

ci(release): generate releases using the new template job

See merge request !33
parents bd43ccc9 da8300c1
No related branches found
No related tags found
3 merge requests!35Publish new release,!34Prepare new release,!33ci(release): generate releases using the new template job
......@@ -33,8 +33,11 @@ build-docker:
- .docker:image:build
###############################################################################
# `release` stage: `semantic-release`, `*-docker-tag`
# `release` stage: `new-release`, `tag *`
###############################################################################
# Create the release versions on `$STABLE_BRANCH`
new release: {extends: '.semantic-release:stable'}
# Suffix all jobs to avoid conflict with other jobs names
.tag-docker:
extends:
......
......@@ -9,16 +9,31 @@ const gitAssets = [];
// Configure your branches names
const stableBranch = 'stable';
// Assign a branch name to produce a `testing` prerelease tag
const testingBranch = undefined;
// Assign a branch name to produce a `beta` prerelease tag
const betaBranch = undefined;
// Assign a branch name to produce a `alpha` prerelease tag
const alphaBranch = undefined;
// Assign a branch name to produce a `dev` prerelease tag
const devBranch = undefined;
// Configure semantic-release plugins
const breakingKeywords = ["BREAKING CHANGE", "BREAKING-CHANGE", "BREAKING CHANGES", "BREAKING-CHANGES"];
const changelogFile = 'docs/CHANGELOG.md';
const semanticBranches = [stableBranch];
if (testingBranch) {
if (betaBranch) {
semanticBranches.push({
name: betaBranch,
prerelease: true
});
}
if (alphaBranch) {
semanticBranches.push({
name: testingBranch,
name: alphaBranch,
prerelease: true
});
}
......@@ -39,10 +54,23 @@ const config = {
'@semantic-release/commit-analyzer',
{
preset: 'angular',
parserOpts:
{
noteKeywords: breakingKeywords,
},
releaseRules: './release-rules.js',
},
],
'@semantic-release/release-notes-generator',
[
'@semantic-release/release-notes-generator',
{
preset: 'angular',
parserOpts:
{
noteKeywords: breakingKeywords,
},
},
],
],
};
......@@ -54,11 +82,11 @@ if (
config.plugins.push([
'@semantic-release/changelog',
{
changelogFile: 'docs/CHANGELOG.md',
changelogFile: changelogFile,
changelogTitle: '# Changelog',
},
]);
gitAssets.push('docs/CHANGELOG.md');
gitAssets.push(changelogFile);
}
// // We need to update package*.json
......@@ -99,89 +127,4 @@ config.plugins.push(
'@semantic-release/gitlab',
);
config.generateNotes = {
preset: 'angular',
writerOpts: {
// Required due to upstream bug preventing all types being displayed.
// Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
// Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["commit", "note"] }] */
transform: (commit, context) => {
const issues = [];
commit.notes.forEach((note) => {
note.title = `BREAKING CHANGES`;
});
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
if (commit.type === `feat`) {
commit.type = `Features`;
} else if (commit.type === `fix`) {
commit.type = `Bug Fixes`;
} else if (commit.type === `perf`) {
commit.type = `Performance Improvements`;
} else if (commit.type === `revert`) {
commit.type = `Reverts`;
} else if (commit.type === `docs`) {
commit.type = `Documentation`;
} else if (commit.type === `style`) {
commit.type = `Styles`;
} else if (commit.type === `refactor`) {
commit.type = `Code Refactoring`;
} else if (commit.type === `test`) {
commit.type = `Tests`;
} else if (commit.type === `build`) {
commit.type = `Build System`;
// } else if (commit.type === `chore`) {
// commit.type = `Maintenance`
} else if (commit.type === `ci`) {
commit.type = `Continuous Integration`;
} else {
return null;
}
if (commit.scope === `*`) {
commit.scope = ``;
}
if (typeof commit.hash === `string`) {
commit.shortHash = commit.hash.substring(0, 7);
}
if (typeof commit.subject === `string`) {
let url = context.repository ? `${context.host}/${context.owner}/${context.repository}` : context.repoUrl;
if (url) {
url = `${url}/issues/`;
// Issue URLs.
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
issues.push(issue);
return `[#${issue}](${url}${issue})`;
});
}
if (context.host) {
// User URLs.
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
if (username.includes('/')) {
return `@${username}`;
}
return `[@${username}](${context.host}/${username})`;
});
}
}
// remove references that already appear in the subject
commit.references = commit.references.filter((reference) => {
if (issues.indexOf(reference.issue) === -1) {
return true;
}
return false;
});
return commit;
},
},
};
module.exports = config;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment