semantic-release / semantic-release

:package::rocket: Fully automated version management and package publishing
https://semantic-release.gitbook.io
MIT License
20.95k stars 1.69k forks source link

Trigger semantic using regex at branch #1518

Open MateusAndrade opened 4 years ago

MateusAndrade commented 4 years ago

Current behavior

Whenever I try to run a release, with my config using the following config:

  "release": {
    "branches": [
      "release/'*'"
    ],
    ....

This causes an error, warning that there isn't any branch matching this pattern.

Expected behavior

However, I would to any branch matching the pattern release/* being able to trigger semantic release. Looking at the docs, I didn't an example of how I would do that.

Any branch matching the pattern release/* trigger semantic-release.

Environment

This may occur if your repository does not have a release branch, such as master.

Your configuration for the problematic branches is [].

pvdlg commented 4 years ago

semantic-release consider only the branches that exists on the remote repo. I'm guessing you don't have any branch on your remote that match that pattern.

MateusAndrade commented 4 years ago

semantic-release consider only the branches that exists on the remote repo. I'm guessing you don't have any branch on your remote that match that pattern.

Yes, for sure. Since we are using Trunk Based Development I needed to apply some changes to our flow.

I decided to use a branch called next to create our releases. Before that, we merge this branch on master and everything works as expected. I don't know if this a good practice, but this attending my needs.

Also, do you mean that if I'm on a branch called release/feature-x, with the config that I posted, I would be able to trigger semantic-release?

Aldorus commented 4 years ago

Hello I had the same issue. I Solved it by removing the "/" in my release branch name

release/deployement-with-semantic => release-deployement-with-semantic

MateusAndrade commented 4 years ago

Hello I had the same issue. I Solved it by removing the "/" in my release branch name

release/deployement-with-semantic => release-deployement-with-semantic

Strange, I will give a try here. Thanks! 😄

ddonahoevibrenthealth commented 3 years ago

@MateusAndrade @Aldorus

Found another cause / fix after a long time researching.

Our issue was that we had lots of existing release/* branches already. The branch regex

"release\/*",

ended up matching lots of old branches, exceeding the 3 allowed by this library. We probably have to update our development flow to accommodate this.

When this fails due to too many matching branches, the output looks like this (mock run):

  semantic-release:get-tags found tags for branch release/arwen: [ { gitTag: 'v3.0.0', version: '3.0.0', channels: [ null ] }, { gitTag: 'v3.0.1-develop.1', version: '3.0.1-develop.1', channels: [ 'develop' ] }, { gitTag: 'v3.0.1-develop.2', version: '3.0.1-develop.2', channels: [ 'develop' ] }, { gitTag: 'v3.1.0', version: '3.1.0', channels: [ 'release/arwen' ] }, { gitTag: 'v3.1.0-develop.1', version: '3.1.0-develop.1', channels: [ 'develop' ] } ] +148ms
  semantic-release:get-tags found tags for branch release/bilbo: [ { gitTag: 'v3.0.0', version: '3.0.0', channels: [ null ] }, { gitTag: 'v3.0.1-develop.1', version: '3.0.1-develop.1', channels: [ 'develop' ] }, { gitTag: 'v3.0.1-develop.2', version: '3.0.1-develop.2', channels: [ 'develop' ] }, { gitTag: 'v3.1.0-develop.1', version: '3.1.0-develop.1', channels: [ 'develop' ] }, { gitTag: 'v4.0.0', version: '4.0.0', channels: [ null ] }, { gitTag: 'v4.1.0-develop.1', version: '4.1.0-develop.1', channels: [ 'develop' ] }, { gitTag: 'v4.1.0-develop.2', version: '4.1.0-develop.2', channels: [ 'develop' ] } ] +181ms
  semantic-release:get-tags found tags for branch release/leia: [] +24ms
  semantic-release:get-tags found tags for branch release/maul: [] +22ms
  semantic-release:get-tags found tags for branch release/norra: [] +23ms
  semantic-release:get-tags found tags for branch release/obi: [] +26ms
  semantic-release:get-tags found tags for branch release/padme: [] +27ms
  semantic-release:get-tags found tags for branch release/qira: [] +26ms
  semantic-release:get-tags found tags for branch release/raven: [] +26ms
  semantic-release:get-tags found tags for branch release/raven-h1: [] +27ms
  semantic-release:get-tags found tags for branch release/raven-h2: [] +26ms
  semantic-release:get-tags found tags for branch release/sith: [] +27ms
  semantic-release:get-tags found tags for branch release/tian: [] +25ms
  semantic-release:get-tags found tags for branch release/ursa: [] +27ms
  semantic-release:get-tags found tags for branch release/vurk: [] +25ms
  semantic-release:get-tags found tags for branch release/windu: [] +27ms
  semantic-release:get-tags found tags for branch release/xwing: [] +27ms
  semantic-release:get-tags found tags for branch release/yoda: [] +26ms
  semantic-release:get-tags found tags for branch release/ziro: [] +25ms

So I believe that if you see lots of matches there, you get the error.

A minimum of 1 and a maximum of 3 release branches are required in the branches configuration.

This may occur if your repository does not have a release branch, such as master.

Honestly just dropping that second "hint" would probably save people tons of time since it's totally unrelated to the actual problem and could send people in the wrong direction.

EDIT: OH, also you have to add a superfluous 'master' entry in the branch object even if you use it for nothing. Just put it there and make sure there's a remote branch as well.

zlodes commented 10 months ago

Any updates here? Would be great to have regex like release/*

ki0 commented 8 months ago

Any update about this?

zlodes commented 7 months ago

I run semantic-release in Gitlab CI and manage branches to run through CI rules. Then I just pass branch name like this:

npx semantic-release --branches $CI_COMMIT_REF_NAME
route33 commented 2 months ago

I run semantic-release in Gitlab CI and manage branches to run through CI rules. Then I just pass branch name like this:

npx semantic-release --branches $CI_COMMIT_REF_NAME

How do you run on detached mod?

zlodes commented 4 days ago

How do you run on detached mod?

What is the detached mode? Have no idea.

route33 commented 4 days ago

How do you run on detached mod?

What is the detached mode? Have no idea.

git detached mode. Nevermind, in the meantime I forgot my initial goal. I switched to some other solution.