5

My goal is configure semantic-release to create tag from the protected branches like this:

npx semantic-release --plugins @semantic-release/commit-analyzer --branches {'name': 'release/super-feature', 'prerelease': true}

I'm expecting that tag 1.0.0-super-feature will be created. However, i'm getting an exception:

[semantic-release] › ✖  EINVALIDBRANCH A branch is invalid in the `branches` configuration.
Each branch in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches) must be either a string, a regexp or an object with a name property.
Your configuration for the problematic branch is ``.
[10:03:55 AM] [semantic-release] › ✖  EINVALIDBRANCH A branch is invalid in the `branches` configuration.
Each branch in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches) must be either a string, a regexp or an object with a name property.
Your configuration for the problematic branch is ``.
AggregateError: 
    SemanticReleaseError: A branch is invalid in the `branches` configuration.
        at module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-error.js:6:10)
        at /usr/local/lib/node_modules/semantic-release/lib/verify.js:36:19
        at Array.forEach (<anonymous>)
        at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:32:12)
        at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
    SemanticReleaseError: A branch is invalid in the `branches` configuration.
        at module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-error.js:6:10)
        at /usr/local/lib/node_modules/semantic-release/lib/verify.js:36:19
        at Array.forEach (<anonymous>)
        at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:32:12)
        at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
    at module.exports (/usr/local/lib/node_modules/semantic-release/lib/verify.js:41:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async run (/usr/local/lib/node_modules/semantic-release/index.js:54:3)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5) {
  name: 'AggregateError'
}

Could you please help me to understand what is wrong - CLI parameters or my expectations?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
user2738882
  • 1,161
  • 1
  • 20
  • 38

1 Answers1

0

Per semantic-release documentation, we're unable to define plugin options via the CLI:

Note: Plugin options cannot be defined via CLI arguments and must be defined in the configuration file.

However, plugin configurations for @semantic-release/exec can be called via CLI arguments. I don't know if this is the case for any other plugins.

@gyomu at #753 provides an example command line with arguments using configuration options from @semantic-release/exec:

npx -p @semantic-release/exec -p semantic-release semantic-release --dry-run --plugins "@semantic-release/commit-analyzer,@semantic-release/exec" --analyzeCommits @semantic-release/commit-analyzer --verifyRelease @semantic-release/exec --verifyReleaseCmd 'echo ${nextRelease.version} > nextRelease.txt'

However, to manipulate branches, I had to do the following:

$ echo '{"branches":["master",{"name":"super-feature","prerelease":true}]}' > .releaserc.json && npx semantic-release --dry-run --no-ci --plugins=@semantic-release/commit-analyzer
...
The next release version is 3.8.0-super-feature.1

Keep in mind, according to the docs, a release branch must be listed, and the target branch must be at the remote location:

Note: If your repository does not have a release branch, then semantic-release will fail with an ERELEASEBRANCHES error message. If you are using the default configuration, you can fix this error by pushing a master branch.

Note: Once semantic-release is configured, any user with the permission to push commits on one of those branches will be able to publish a release. It is recommended to protect those branches, for example with GitHub protected branches.

I also found that I was unable to use a forward slash (/) in the branch name. So, consider using super-feature instead.

jcandan
  • 11
  • 2