Skip to content

Commit 5566f10

Browse files
authored
Merge pull request #6152 from element-hq/feature/bma/releaseVersion
[Release script] Ensure that the release version will match the next Monday date
2 parents 20406ec + eff3aae commit 5566f10

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tools/release/release.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,25 @@ git pull
9797
printf "\n================================================================================\n"
9898
# Guessing version to propose a default version
9999
versionsFile="./plugins/src/main/kotlin/Versions.kt"
100-
# Get current year on 2 digits
101-
versionYearCandidate=$(date +%y)
100+
# The version of the release must match the date of next monday, where the release is supposed to go live
101+
# The command below gets the date of next monday
102+
nextMondayDateCommand="date -v +1w -v -monday"
103+
# Get release year on 2 digits
104+
versionYearCandidate=$(${nextMondayDateCommand} +%y)
102105
currentVersionMonth=$(grep "val versionMonth" ${versionsFile} | cut -d " " -f6)
103-
# Get current month on 2 digits
104-
versionMonthCandidate=$(date +%m)
106+
# Get release month on 2 digits
107+
versionMonthCandidate=$(${nextMondayDateCommand} +%m)
105108
versionMonthCandidateNoLeadingZero=${versionMonthCandidate/#0/}
106109
currentVersionReleaseNumber=$(grep "val versionReleaseNumber" ${versionsFile} | cut -d " " -f6)
107-
# if the current month is the same as the current version, we increment the release number, else we reset it to 0
110+
# if the release month is the same as the current version, we increment the release number, else we reset it to 0
108111
if [[ ${currentVersionMonth} -eq ${versionMonthCandidateNoLeadingZero} ]]; then
109112
versionReleaseNumberCandidate=$((currentVersionReleaseNumber + 1))
110113
else
111114
versionReleaseNumberCandidate=0
112115
fi
113116
versionCandidate="${versionYearCandidate}.${versionMonthCandidate}.${versionReleaseNumberCandidate}"
114117

115-
read -r -p "Please enter the release version (example: ${versionCandidate}). Format must be 'YY.MM.x' or 'YY.MM.xy'. Just press enter if ${versionCandidate} is correct. " version
118+
read -r -p "Please enter the release version (example: ${versionCandidate}). Format must be 'YY.MM.x' or 'YY.MM.xy', with year and month matching next Monday. Just press enter if ${versionCandidate} is correct. " version
116119
version=${version:-${versionCandidate}}
117120

118121
# extract year, month and release number for future use

0 commit comments

Comments
 (0)