Automatic Versioning Based on Branch Names Using Semantic-Release Package

53 views Asked by At

Hello Stack Overflow community,

I am currently exploring the capabilities of the semantic-release package and wondering if it is possible to update versioning based on branch names instead of commit messages. Specifically, I have a 'next' branch that serves as a release candidate. Whenever I merge a feature into it, the branch name always starts with 'feature/'. My goal is to automatically update the minor versioning when features are merged into 'next', and similarly, update patch versioning for branches starting with 'bugfix/'.

To provide a clear scenario:

  • If a feature branch (e.g., 'feature/new-feature') is merged into the 'next' branch, can semantic-release automatically increment the minor version?
  • If a bugfix branch (e.g., 'bugfix/issue-fix') is merged into the 'next' branch, can semantic-release automatically increment the patch version?
  • Furthermore, once the 'next' branch is pushed to 'master', the versioning should be finalized and reflect the actual release version.

I have extensively searched the documentation and online resources but haven't found a clear solution for this specific use case. I would appreciate any insights or suggestions on how to achieve this versioning strategy with semantic-release.

Thank you in advance for your help!

I have tried the following configurations already which did not meet my requirements:

module.exports = {
    branches: [
        'master',
        { name: 'next', prerelease: 'rc' },
        { name: 'feature/*', channel: 'minor' },
        { name: 'bugfix/*', channel: 'patch' },
    ],
    plugins: [
        '@semantic-release/commit-analyzer',
        '@semantic-release/release-notes-generator',
        '@semantic-release/changelog',
        '@semantic-release/npm',
        '@semantic-release/git',
    ],
};

And

module.exports = {
    branches: [
        'master',
        { name: 'next', prerelease: 'rc' },
        { name: 'feature/*', prerelease: true },
        { name: 'bugfix/*', prerelease: true },
    ],
    plugins: [
        '@semantic-release/commit-analyzer',
        '@semantic-release/release-notes-generator',
        '@semantic-release/changelog',
        '@semantic-release/npm',
        '@semantic-release/git',
    ],
};

Both of them gave me a ERELEASEBRANCHES error with the message being "A minimum of 1 and a maximum of 3 release branches are required in the branches configuration.".

0

There are 0 answers