2

I am trying to create semantic releases with a tag format which includes the branch name. The .releaserc file looks something like this:

{
    "name": "Inder Semantic Release",
    "version": "2.1.0",
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator"
    ],
    "tagFormat": "${want_branch_name_here}-${version}",
    "branches": ['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}, {name: 'gpu', prerelease: true}, {name: 'non-root'}]    
}

I will want to get the branch name in the tag format automatically (i.e. replace ${want_branch_name_here} with the required var that will have the value of branch name), is there a way to achieve that?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Inder
  • 3,711
  • 9
  • 27
  • 42
  • Per https://semantic-release.gitbook.io/semantic-release/usage/configuration#tagformat - _"The tag name ... will be compiled with the `version` variable."_ This implies that no other variables will be available. – jonrsharpe Jul 28 '21 at 09:01
  • @jonrsharpe Thanks for your response, i understand that it must contain a value for the version but we can still pass on other variables, i.e. some we create or the others that already exist, I am trying to get hold of something around that. I mean I can create a tag like `master-${version}` manually – Inder Jul 28 '21 at 09:03
  • *"we can still pass on other variables"* - I'm not sure what makes you think that, that's not what the linked documentation suggests. – jonrsharpe Jul 28 '21 at 09:05
  • @jonrsharpe sorry I missed that u think using `semantic-release/exec` to run a pre cmd or something can help ? example [here](https://semantic-release.gitbook.io/semantic-release/support/faq) – Inder Jul 28 '21 at 09:11

1 Answers1

3

Try giving tags while executing command semantic-release rather than defining tagFormat in releaserc

npx semantic-release -t v\${version}-$(git rev-parse --abbrev-ref HEAD)

Gives you a version like v1.0.2-master

Typhoon
  • 178
  • 2
  • 10