rising3 / semver-gradle-plugin

Gradle plugin for Updates the project version.A plugin that can updating the semantic versions like `yarn version` command.
Apache License 2.0
15 stars 7 forks source link

Get current version from latest tag #3

Closed rising3 closed 3 years ago

rising3 commented 3 years ago

Add new feature for Get current version from latest tag.

Summary

FILE MODE:

  1. Get current version from file. (gradle.properties, package.json, etc.)
  2. Update to new version, save to files.
  3. Create a git commit of save files.
  4. Create a git tag of new version.

TAG MODE:

  1. Get latest tag for git.
  2. Analyze tag, convert to semantic version.(current version)
  3. Update to new version, save to file.
  4. Create a git tag of new version.
  5. Push tag to remote.
GIT CONTROL FILE MODE(DEFAULT) TAG MODE(DEFAULT)
CREATE(UPDATE) VERSION FILES Y Y
CREATE VERSION COMMIT Y N
CREATE VERSION TAG Y Y
PUSH COMMIT N N
PUSH TAG N Y

Plugin Extension

The following add/change properties: Property Name Type Default value Description
[NEW]
manageVersion
String 'file' Choice 'FILE' or 'TAG' .
[CHANGE]
filename
String 'gradle.properties' Change the filename of version property.
(FILE MODE Only)
[CHANGE]
noGitCommand
boolean false Even enable or disable the git command behavior entirely.
(FILE MODE Only)
[CHANGE]
noGitInit
boolean true Even enable or disable the git init behavior entirely.
(FILE MODE Only)
[NEW]
noGitCommitVersion
boolean false Even enable or disable the git commit behavior entirely.
(FILE MODE Only)
[CHANGE]
noGitTagVersion
boolean false Even enable or disable the git tagging behavior entirely.
(FILE MODE Only)
[NEW]
noGitPush
boolean true Even enable or disable the git push behavior entirely.
(FILE MODE Only)
[NEW]
noGitPushTag
boolean true Even enable or disable the git push tag behavior entirely.
(FILE MODE Only)
nloboda commented 3 years ago

Getting version from tag makes perfect sense.

However it might be tricky to make it work with several branches. For example: you've version 1.x and 2.x and branches release_1 (you tag from this branch say, v1.0.1, v.1.0.2, v.1.1.9 ) release_2 (you tag from this branch, say v2.0.4, v.2.0.6, v.2.6.2 )

say latest version was v.2.6.2, then if you try to release next version from 1.x branch it will be bumped to 2.6.3.

Different solution might be getting latest tag from branch you're currently. in this case bump from v.1.1.9 will be v.1.1.10 and from v.2.6.2 will be v.2.6.3 which allow users to maintain several active versions.

Would be really nice to chat with you over this issue, and I think I could send you merge request this Sunday or something.

rising3 commented 3 years ago

@nloboda

It's a good point.I'm aware of the point. When releasing on a maintenance branch, we plan to guess the branch name and get the next version from the branch name.

TAG LISTS

e.g.) when releasing on 1.0.x branch

However, if you are releasing on the maintenance branch, you must meet the following requirements:

thx.

nloboda commented 3 years ago

Thanks. I'll try to come up with something tomorrow

nloboda commented 3 years ago

Hi @rising3 ,

I've did some work on storing versions in tags. https://github.com/nloboda/semver-gradle-plugin/pull/1/files

This is JFYI update, I don't feel like it's ready to be merged yet. I'll try to adjust this to adhere ticket specification and coding standard tomorrow. and drop-in update.

Thanks!

nloboda commented 3 years ago

@rising3

Hi, I kindly request for comments on pr. https://github.com/rising3/semver-gradle-plugin/pull/5

Regards, Nikolay.