This function generates a date-based version number. Year + Month + Iteration
So, the first release in March 2017 will be 17.3.0
If multiple releases occur in a month, the final number will increase. Otherwise, an entirely new verion number will be generated.
i.e.
generateVersionNumber('17.12.10');
Output:
Given that the date is 2017-12-01 (day is irrelevant)
17.12.11
Source:
function generateVersionNumber(previousVersion){
let today = new Date();
var newMajor = `${today.getFullYear()}.${parseInt(today.getMonth()) + 1}`
newMajor = newMajor.substr(2);
oldMajorArr = previousVersion.split('.')
oldMajor = `${oldMajorArr[0]}.${oldMajorArr[1]}`
if(oldMajor == newMajor){
newVersion = `${newMajor}.${parseInt(oldMajorArr[2]) + 1}`
} else {
newVersion = newMajor + '.0'
}
return newVersion;
}