semantic-release: Cannot pass build number to use in tag format
Current behavior
If I add build number to tag format as "tagFormat": "v${version}+${process.env.build_number}", semantic release fails to analyse commits correctly.
Check out this repo: https://github.com/AndriyGo/semanticTest. A tag v1.0.0+1 exists. However, no matter from which branch I call build_number=2 npx semantic-release it wants to create a new release. If I call build_number=1 npx semantic-release it detects tag v1.0.0+1 and doesn’t publish a release. So, looks like it doesn’t want to ignore build number and considers +${process.env.build_number} to be an important identifier. Hence, when analysing commits, it only analyses if releases which end with +${process.env.build_number} exist.
This is a bug because as was suggested by @pvdlg in #835 this is supposed to be a workaround for passing build number which would otherwise be ignored by semantic release. However, it treats the change in build number the same way as it would treat the migration of tag format from v${version} to version${version}…
Expected behavior
It is supposed to correctly detect that tag v1.0.0+1 is a proper release whose version is 1.0.0 and create releases from there.
semantic-release version
v23.1.1
CI environment
terminal
Plugins used
commit-analyzer release-notes-generator
semantic-release configuration
{ “ci”: false, “branches”: [“main”, {name: ‘develop’, prerelease: true}], “tagFormat”: “v${version}+${process.env.build_number}”, “plugins”: [‘@semantic-release/commit-analyzer’, ‘@semantic-release/release-notes-generator’] }
CI logs
From main branch:
[5:58:20 PM] [semantic-release] › ℹ Running semantic-release version 23.1.1 [5:58:20 PM] [semantic-release] › ✔ Loaded plugin “analyzeCommits” from “@semantic-release/commit-analyzer” [5:58:20 PM] [semantic-release] › ✔ Loaded plugin “generateNotes” from “@semantic-release/release-notes-generator” [5:58:23 PM] [semantic-release] › ✔ Run automated release from branch main on repository https://github.com/AndriyGo/semanticTest.git [5:58:24 PM] [semantic-release] › ✔ Allowed to push to the Git repository [5:58:24 PM] [semantic-release] › ℹ No git tag version found on branch main [5:58:24 PM] [semantic-release] › ℹ No previous release found, retrieving all commits [5:58:24 PM] [semantic-release] › ℹ Found 3 commits since last release [5:58:24 PM] [semantic-release] › ℹ Start step “analyzeCommits” of plugin “@semantic-release/commit-analyzer” [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: ci: fix reseaserc syntax [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The commit should not trigger a release [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: fix:Let’s test semantic version [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The commit should not trigger a release [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: feat: Initial commit [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is minor [5:58:24 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analysis of 3 commits complete: minor release [5:58:24 PM] [semantic-release] › ✔ Completed step “analyzeCommits” of plugin “@semantic-release/commit-analyzer” [5:58:24 PM] [semantic-release] › ℹ There is no previous release, the next release version is 1.0.0 [5:58:24 PM] [semantic-release] › ℹ Start step “generateNotes” of plugin “@semantic-release/release-notes-generator” [5:58:24 PM] [semantic-release] › ✔ Completed step “generateNotes” of plugin “@semantic-release/release-notes-generator” [5:58:28 PM] [semantic-release] › ✔ Created tag v1.0.0+2 [5:58:28 PM] [semantic-release] › ✔ Published release 1.0.0 on default channel
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (10 by maintainers)
Sure, I can outline my use case, although I do think that it is a bit irrelevant in this case. As stated in the semantic-release docs
So, as we talk about a case in which semantic-release is not following the spec which it is supposed to follow – it looks like a bug which should be fixed 😃
Anyway my use case is the following. I have several apps in the same repository. For ease, think about a free version and a paid version. I strictly use semantic-release for versioning, but sometimes I do not update apps at the same time.
Let’s say I developed a feature and want to try it out in the free version first. So I publish, let’s say v1.1.0 and release my free app with build number 2.
Then, while I am gathering data – I improve my CI implementation with one commit. After this I decide that I want to ship this feature to the paid app as well.
I run semantic-release in dry mode and see that no new release is available. So, I can set the same version as was in my last release. However, I do not want to set the same build version because even though my commits since last release do not deserve a new version - my repo was changed. I am not on the same commit as before and I want to differentiate it.
So I want to ship my paid app as v1.1.0 but with build version 3. And I would like to have two tags in this case - v1.1.0+2 and v1.1.0+3.
This way if I ever need to debug the app - I know exactly at what point and against which repo codebase each version was shipped.
Another use case was outlined in #835 which I have quoted originally