momocow / semantic-release-gitmoji

✨🐛💥 A semantic-release plugin for gitmojis. Different from conventional changelog, Gitmoji commits are used to determine a release type and generate release notes.
MIT License
86 stars 20 forks source link

Generate tags with -SNAPSHOT on it from the Develop branch (when running semantic-release-gitmoji) #94

Closed arkadioz closed 4 months ago

arkadioz commented 5 months ago

Hi @momocow hope you are doing well, I got a question again on how to do something that im not sure if the tool is able to do, it is easier to explain with the use case/example:

Imagine I have a feature branch and then I merge it to Develop branch, so I trigger semantic-release-gitmoji on Develop branch and when the tag is generated I want it to have this format x.y.z-SNAPSHOT, for example suppose the Merged feature generates the tag 18.0.1-SNAPSHOT, then when im done testing I merge Develop into Main and run semantic-release-gitmoji and get the tag 18.0.1

I do not think that is possible, I was thinking that maybe if you configure the Develop branch as a prerelease branch at the .releaserc.js and have a tagFormat like ${version}-SNAPSHOT (I do not think this will work as expected? it will probably do 18.0.1-SNAPSHOT-Develop.1 instead of the expected 18.0.1-SNAPSHOT), but then you would also need to use 2 different .releaserc.js files, so that the tagFormat of the semantic-release-gitmoji that is run on the Main branch is x.y.z (so this 2nd or 1st however you prefer .releaserc.js has that tagFormat), but again I think this is not gonna work as expected right, I will test this but I have no hope that it will work as expected, anyways if you know how to make it work like im describing here I appreciate any help :)

Note: I know prerelease branches work generating tags with the format x.y.z-branchname.n like 18.0.1-Develop.1, but wanna know if it is also possible to do it like I described.

arkadioz commented 5 months ago

Also if it is not possible, I think it would actually be good because, after that first Merge into Develop that generates the tag 18.0.1-SNAPSHOT, suppose you merge another patch into Develop, run semantic-release-gitmoji, what is the tool supposed to do if it is going to try to generate again 18.0.1-SNAPSHOT, so I think this answer my own question, this is why it needs the format like 18.0.1-SNAPSHOT-Develop.1, then 18.0.1-SNAPSHOT-Develop.2 and so on (reminding that Develop is configured as prerelease ofcourse), but anyways I wait for your reply @momocow

the only way I see that what I described above could work is that the tool can do tags like x.y.z-SNAPSHOT.n for example 18.0.1-SNAPSHOT.1 when running from the Develop branch but I do not think that you can set that with the tagFormat or somehow right?

arkadioz commented 5 months ago

TEST RESULTS (Using tagFormat: '${version}' for main branch and tagFormat: '${version}-SNAPSHOT' for develop (this breaks the tag consistency)):

I did a test and I think this is not possible, I used the tagFormat: '${version}-SNAPSHOT' at the develop releaserc.js, and then used the tagFormat: '${version}' at the main releaserc.js, and this made the plugin unable to keep consistency in tag history, so for example my repo latest tag is 18.0.0, but when running the prerelease from develop (ofcourse I merged main into develop before doing this so it had all the tag history too and commits) it made the tag 1.0.0-develop.1-SNAPSHOT (this was the first surprise as I expected it to dont do anything since latest tag is 18.0.0 and no new changes were made since then, this is what would normally happen when using same tagFormat for release and prerelease) and used all the commits from the begining of the project, then I made a patch feature and put it directly in main, then ran the semantic-release from main (here tag format was still just ${version}) and it kept consistency by doing 18.0.1, then I merged main into develop hoping it to now "fix" or "know" the proper tag history but nope, develop then made the tag 1.0.0-develop.2-SNAPSHOT, so then I modified the .releaserc.js used by develop to have the same tag format as main which is tagFormat: '${version}', made a new feature branch from develop merged it into it to simulate a minor change, ran semantic-release from develop and after that it successfully made the tag 18.1.0-develop.1 (consistent with tag history again), so this confirms 2 things: