build(docs): introduce release script
This change introduces a new NPM run script to automatically generate
the release changelog, as well as bump version numbers across the
code-base and create the release tag.
This script runs [Standard Version] to execute this, which is a tool
designed around automating substantial parts of the release process.
This can be done by running:
npm run release -- [<standard-version args>]
Standard Version expects the project to adhere to the [Semantic
Versioning] convention which TF-A does not, so you may need to specify
the version manually, e.g.:
npm run release -- --release-as 2.6.0
Individual steps of the release process may also be skipped at-will,
which may be necessary when, for example, tweaking the changelog:
npm run release -- --skip.commit --skip.tag
Standard Version is configured by the `.versionrc.js` file, which
contains information about the Conventional Commits types and scopes
used by the project, and how they map to the changelog.
To maintain continuity with the existing changelog style - at least to
the extent possible in the move from manual to automatic creation - a
customized changelog template has been introduced, based on the
Conventional Commits template provided by Standard Version.
This template package extends the Conventional Commits template package
by introducing support for parsing the Conventional Commits scopes into
changelog sections, similarly to how they were previously organized.
[Standard Version]:
https://github.com/conventional-changelog/standard-version
[Semantic Versioning]: https://semver.org
Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/.commitlintrc.js b/.commitlintrc.js
index 648246c..3bd68bb 100644
--- a/.commitlintrc.js
+++ b/.commitlintrc.js
@@ -11,6 +11,24 @@
const cz = require("./.cz.json");
const { "trailer-exists": trailerExists } = require("@commitlint/rules").default;
+/*
+ * Recursively fetch the project's supported scopes from the Commitizen configuration file. We use
+ * permit only the blessed scope for each section to encourage developers to use a consistent scope
+ * scheme.
+ */
+function getScopes(sections) {
+ return sections.flatMap(section => {
+ const scopes = section.scopes;
+ const subscopes = getScopes(section.sections || []);
+
+ const scope = scopes ? [ scopes[0] ] : []; /* Only use the blessed scope */
+
+ return scope.concat(subscopes);
+ })
+};
+
+const scopes = getScopes(cz.sections); /* Contains every blessed scope */
+
module.exports = {
extends: ["@commitlint/config-conventional"],
plugins: [
@@ -27,5 +45,8 @@
"change-id-exists": [1, "always", "Change-Id:"], /* Warning */
"signed-off-by-exists": [1, "always", "Signed-off-by:"], /* Warning */
+
+ "scope-case": [2, "always", "kebab-case"], /* Error */
+ "scope-enum": [1, "always", scopes] /* Warning */
},
};