diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 188bbe47..be5d7f3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,7 @@ jobs: run: npm config list && npm run release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN_RELEASE: ${{ secrets.PAT_TOKEN }} GA_USERNAME: ${{ secrets.PAT_USERNAME }} GA_TOKEN: ${{ secrets.PAT_TOKEN }} diff --git a/.releaserc b/.releaserc deleted file mode 100644 index ca5116d6..00000000 --- a/.releaserc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "branches": ["master"], - "tagFormat": "${version}", - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/changelog", - "@semantic-release/github", - "@semantic-release/npm", - [ - "semantic-release-github-pullrequest-fixed", { - "assets": ["CHANGELOG.md", "package.json"], - "baseRef": "master" - } - ] - ] -} \ No newline at end of file diff --git a/commit-format.cjs b/commit-format.cjs new file mode 100644 index 00000000..51624702 --- /dev/null +++ b/commit-format.cjs @@ -0,0 +1,30 @@ +// Shared commit message parser used by commitlint (commitlint.config.cjs) and +// semantic-release (release.config.cjs). Accepts both the BigCommerce ticket-first +// format enforced by @bigcommerce/validate-commits and the legacy conventional format: +// TRAC-123: type(scope) - subject +// type(scope): TRAC-123 subject +const parserOpts = { + headerPattern: /^(?:[A-Z0-9]{2,}-\d+: )?(\w+)(?:\(([^)]*)\))?!?(?::| -) (.+)$/, + breakingHeaderPattern: /^(?:[A-Z0-9]{2,}-\d+: )?(\w+)(?:\(([^)]*)\))?!(?::| -) (.+)$/, + headerCorrespondence: ['type', 'scope', 'subject'], +}; + +// Union of @commitlint/config-conventional and @bigcommerce/validate-commits types +const types = [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'license', + 'meta', + 'perf', + 'ref', + 'refactor', + 'revert', + 'style', + 'test', +]; + +module.exports = { parserOpts, types }; diff --git a/commitlint.config.cjs b/commitlint.config.cjs index 1c03cd1c..39ffdede 100644 --- a/commitlint.config.cjs +++ b/commitlint.config.cjs @@ -1,6 +1,10 @@ +const { parserOpts, types } = require('./commit-format.cjs'); + module.exports = { extends: ['@commitlint/config-conventional'], + parserPreset: { parserOpts }, rules: { 'subject-case': [0, 'always', 'sentence-case'], + 'type-enum': [2, 'always', types], }, }; diff --git a/release.config.cjs b/release.config.cjs new file mode 100644 index 00000000..4ff2a286 --- /dev/null +++ b/release.config.cjs @@ -0,0 +1,21 @@ +const { parserOpts } = require('./commit-format.cjs'); + +module.exports = { + branches: ['master'], + // eslint-disable-next-line no-template-curly-in-string + tagFormat: '${version}', + plugins: [ + ['@semantic-release/commit-analyzer', { parserOpts }], + ['@semantic-release/release-notes-generator', { parserOpts }], + '@semantic-release/changelog', + '@semantic-release/github', + '@semantic-release/npm', + [ + 'semantic-release-github-pullrequest-fixed', + { + assets: ['CHANGELOG.md', 'package.json'], + baseRef: 'master', + }, + ], + ], +};