Skip to content

Sort versions with node-semver, convert to git tag

Fabien Catteau requested to merge sort-git-tags-node-semver-leading-v into master

What does this MR do?

Use https://github.com/npm/node-semver to sort git tags, because sort -V doesn't sort prereleases properly.

It's based on !319 (merged) but fixes it: it prepends v to the version returned by semver to get the git tag.

Testing

Tested locally with docker:20.10.

/tmp/gemnasium # CHANGELOG_MAJOR_VERSION=2
/tmp/gemnasium #         LAST_VERSION=$(semver $(git tag -l|grep -e v$CHANGELOG_MAJOR_VERSION'\.\d\+\.\d\+')|tail -n 1)
/tmp/gemnasium #         # Prepend "v" to the SemVer version to get the git tag
/tmp/gemnasium #         CI_COMMIT_TAG="v$LAST_VERSION"
/tmp/gemnasium # echo $CI_COMMIT_TAG
/tmp/gemnasium # CHANGELOG_MAJOR_VERSION=3
/tmp/gemnasium #         LAST_VERSION=$(semver $(git tag -l|grep -e v$CHANGELOG_MAJOR_VERSION'\.\d\+\.\d\+')|tail -n 1)
/tmp/gemnasium #         CI_COMMIT_TAG="v$LAST_VERSION"
/tmp/gemnasium # echo $CI_COMMIT_TAG
v3.0.0
Edited by Fabien Catteau

Merge request reports