Merge pull request #4187 from element-hq/feature/bma/calver
Migrate to CalVer like versioning
This commit is contained in:
commit
6713bdbdd2
2 changed files with 33 additions and 61 deletions
|
|
@ -9,49 +9,30 @@ import org.gradle.api.JavaVersion
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version codes are quite sensitive, because there is a mix between bundle and APKs, and we have to take into
|
* Version codes are quite sensitive, because there is a mix between bundle and APKs.
|
||||||
* account the future upgrade of Element Android.
|
|
||||||
* Max versionCode allowed by the PlayStore (for information):
|
* Max versionCode allowed by the PlayStore (for information):
|
||||||
* 2_100_000_000
|
* 2_100_000_000
|
||||||
* Current version code of EAx on the PlayStore, for the first uploaded beta (we cannot go below):
|
|
||||||
* ----1_001_000
|
|
||||||
* Current version code of EAx on the nightly:
|
|
||||||
* ----1_001_000
|
|
||||||
* Current version of Element Android (at some point EAx will replace this app) (v1.6.3)
|
|
||||||
* ----40_106_03a where a stands for the architecture: 1, 2, 3, 4 and 0 for the universal APK
|
|
||||||
* Current version of EAx distributed with Firebase app distribution:
|
|
||||||
* ----1_002_000
|
|
||||||
* Latest version of EAx distributed with Firebase app distribution (downgrading, so that's a problem)
|
|
||||||
* -------10_200
|
|
||||||
* Version when running the current debug build
|
|
||||||
* -------10_200
|
|
||||||
*
|
*
|
||||||
* So adding 4_000_000 to the current version Code computed here should be fine, and since the versionCode
|
* Also note that the versionCode is multiplied by 10 in app/build.gradle.kts#L168:
|
||||||
* is multiplied by 10 in app/build.gradle.kts#L168:
|
|
||||||
* ```
|
* ```
|
||||||
* output.versionCode.set((output.versionCode.get() ?: 0) * 10 + abiCode))
|
* output.versionCode.set((output.versionCode.get() ?: 0) * 10 + abiCode))
|
||||||
* ```
|
* ```
|
||||||
* we will have:
|
* We are using a CalVer-like approach to version the application. The version code is calculated as follows:
|
||||||
* Release version:
|
* - 4 digits for the year
|
||||||
* ---40_001_020
|
* - 2 digits for the month
|
||||||
* Nightly version:
|
* - 2 digits for the release number
|
||||||
* ---40_001_020
|
* So for instance, the first release of Jan 2025 will have the version code: 20250100 (20_250_100)
|
||||||
* Debug version:
|
|
||||||
* ---40_010_200
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Note: 2 digits max for each value
|
private const val versionYear = 2025
|
||||||
private const val versionMajor = 0
|
private const val versionMonth = 1
|
||||||
private const val versionMinor = 7
|
|
||||||
|
|
||||||
// Note: even values are reserved for regular release, odd values for hotfix release.
|
// Note: must be in [0,99]
|
||||||
// When creating a hotfix, you should decrease the value, since the current value
|
private const val versionReleaseNumber = 0
|
||||||
// is the value for the next regular release.
|
|
||||||
private const val versionPatch = 7
|
|
||||||
|
|
||||||
object Versions {
|
object Versions {
|
||||||
const val VERSION_CODE = 4_000_000 + versionMajor * 1_00_00 + versionMinor * 1_00 + versionPatch
|
const val VERSION_CODE = versionYear * 10_000 + versionMonth * 100 + versionReleaseNumber
|
||||||
const val VERSION_NAME = "$versionMajor.$versionMinor.$versionPatch"
|
const val VERSION_NAME = "$versionYear.$versionMonth.$versionReleaseNumber"
|
||||||
const val COMPILE_SDK = 35
|
const val COMPILE_SDK = 35
|
||||||
const val TARGET_SDK = 35
|
const val TARGET_SDK = 35
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,19 +94,25 @@ git pull
|
||||||
printf "\n================================================================================\n"
|
printf "\n================================================================================\n"
|
||||||
# Guessing version to propose a default version
|
# Guessing version to propose a default version
|
||||||
versionsFile="./plugins/src/main/kotlin/Versions.kt"
|
versionsFile="./plugins/src/main/kotlin/Versions.kt"
|
||||||
versionMajorCandidate=$(grep "val versionMajor" ${versionsFile} | cut -d " " -f6)
|
versionYearCandidate=$(date +%Y)
|
||||||
versionMinorCandidate=$(grep "val versionMinor" ${versionsFile} | cut -d " " -f6)
|
currentVersionMonth=$(grep "val versionMonth" ${versionsFile} | cut -d " " -f6)
|
||||||
versionPatchCandidate=$(grep "val versionPatch" ${versionsFile} | cut -d " " -f6)
|
versionMonthCandidate=$(date +%-m)
|
||||||
versionCandidate="${versionMajorCandidate}.${versionMinorCandidate}.${versionPatchCandidate}"
|
currentVersionReleaseNumber=$(grep "val versionReleaseNumber" ${versionsFile} | cut -d " " -f6)
|
||||||
|
# if the current month is the same as the current version, we increment the release number, else we reset it to 0
|
||||||
|
if [[ ${currentVersionMonth} -eq ${versionMonthCandidate} ]]; then
|
||||||
|
versionReleaseNumberCandidate=$((currentVersionReleaseNumber + 1))
|
||||||
|
else
|
||||||
|
versionReleaseNumberCandidate=0
|
||||||
|
fi
|
||||||
|
versionCandidate="${versionYearCandidate}.${versionMonthCandidate}.${versionReleaseNumberCandidate}"
|
||||||
|
|
||||||
read -p "Please enter the release version (example: ${versionCandidate}). Just press enter if ${versionCandidate} is correct. " version
|
read -p "Please enter the release version (example: ${versionCandidate}). Just press enter if ${versionCandidate} is correct. " version
|
||||||
version=${version:-${versionCandidate}}
|
version=${version:-${versionCandidate}}
|
||||||
|
|
||||||
# extract major, minor and patch for future use
|
# extract major, minor and patch for future use
|
||||||
versionMajor=$(echo "${version}" | cut -d "." -f1)
|
versionYear=$(echo "${version}" | cut -d "." -f1)
|
||||||
versionMinor=$(echo "${version}" | cut -d "." -f2)
|
versionMonth=$(echo "${version}" | cut -d "." -f2)
|
||||||
versionPatch=$(echo "${version}" | cut -d "." -f3)
|
versionReleaseNumber=$(echo "${version}" | cut -d "." -f3)
|
||||||
nextPatchVersion=$((versionPatch + 1))
|
|
||||||
|
|
||||||
printf "\n================================================================================\n"
|
printf "\n================================================================================\n"
|
||||||
printf "Starting the release ${version}\n"
|
printf "Starting the release ${version}\n"
|
||||||
|
|
@ -122,20 +128,18 @@ fi
|
||||||
# Ensure version is OK
|
# Ensure version is OK
|
||||||
versionsFileBak="${versionsFile}.bak"
|
versionsFileBak="${versionsFile}.bak"
|
||||||
cp ${versionsFile} ${versionsFileBak}
|
cp ${versionsFile} ${versionsFileBak}
|
||||||
sed "s/private const val versionMajor = .*/private const val versionMajor = ${versionMajor}/" ${versionsFileBak} > ${versionsFile}
|
sed "s/private const val versionYear = .*/private const val versionYear = ${versionYear}/" ${versionsFileBak} > ${versionsFile}
|
||||||
sed "s/private const val versionMinor = .*/private const val versionMinor = ${versionMinor}/" ${versionsFile} > ${versionsFileBak}
|
sed "s/private const val versionMonth = .*/private const val versionMonth = ${versionMonth}/" ${versionsFile} > ${versionsFileBak}
|
||||||
sed "s/private const val versionPatch = .*/private const val versionPatch = ${versionPatch}/" ${versionsFileBak} > ${versionsFile}
|
sed "s/private const val versionReleaseNumber = .*/private const val versionReleaseNumber = ${versionReleaseNumber}/" ${versionsFileBak} > ${versionsFile}
|
||||||
rm ${versionsFileBak}
|
rm ${versionsFileBak}
|
||||||
|
|
||||||
# This commit may have no effect because generally we do not change the version during the release.
|
|
||||||
git commit -a -m "Setting version for the release ${version}"
|
git commit -a -m "Setting version for the release ${version}"
|
||||||
|
|
||||||
printf "\n================================================================================\n"
|
printf "\n================================================================================\n"
|
||||||
printf "Creating fastlane file...\n"
|
printf "Creating fastlane file...\n"
|
||||||
printf -v versionMajor2Digits "%02d" "${versionMajor}"
|
printf -v versionMonth2Digits "%02d" "${versionMonth}"
|
||||||
printf -v versionMinor2Digits "%02d" "${versionMinor}"
|
printf -v versionReleaseNumber2Digits "%02d" "${versionReleaseNumber}"
|
||||||
printf -v versionPatch2Digits "%02d" "${versionPatch}"
|
fastlaneFile="${versionYear}${versionMonth2Digits}${versionReleaseNumber2Digits}0.txt"
|
||||||
fastlaneFile="4${versionMajor2Digits}${versionMinor2Digits}${versionPatch2Digits}0.txt"
|
|
||||||
fastlanePathFile="./fastlane/metadata/android/en-US/changelogs/${fastlaneFile}"
|
fastlanePathFile="./fastlane/metadata/android/en-US/changelogs/${fastlaneFile}"
|
||||||
printf "Main changes in this version: TODO.\nFull changelog: https://github.com/element-hq/element-x-android/releases" > "${fastlanePathFile}"
|
printf "Main changes in this version: TODO.\nFull changelog: https://github.com/element-hq/element-x-android/releases" > "${fastlanePathFile}"
|
||||||
|
|
||||||
|
|
@ -163,19 +167,6 @@ printf "\n======================================================================
|
||||||
printf "Checking out develop...\n"
|
printf "Checking out develop...\n"
|
||||||
git checkout develop
|
git checkout develop
|
||||||
|
|
||||||
# Set next version
|
|
||||||
printf "\n================================================================================\n"
|
|
||||||
printf "Setting next version on file '${versionsFile}'...\n"
|
|
||||||
cp ${versionsFile} ${versionsFileBak}
|
|
||||||
sed "s/private const val versionPatch = .*/private const val versionPatch = ${nextPatchVersion}/" ${versionsFileBak} > ${versionsFile}
|
|
||||||
rm ${versionsFileBak}
|
|
||||||
|
|
||||||
printf "\n================================================================================\n"
|
|
||||||
read -p "I have updated the versions to prepare the next release, please check that the change are correct and press enter so I can commit. "
|
|
||||||
|
|
||||||
printf "Committing...\n"
|
|
||||||
git commit -a -m 'version++'
|
|
||||||
|
|
||||||
printf "\n================================================================================\n"
|
printf "\n================================================================================\n"
|
||||||
printf "The GitHub action https://github.com/element-hq/element-x-android/actions/workflows/release.yml?query=branch%%3Amain should have start a new run.\n"
|
printf "The GitHub action https://github.com/element-hq/element-x-android/actions/workflows/release.yml?query=branch%%3Amain should have start a new run.\n"
|
||||||
read -p "Please enter the url of the run, no need to wait for it to complete (example: https://github.com/element-hq/element-x-android/actions/runs/9065756777): " runUrl
|
read -p "Please enter the url of the run, no need to wait for it to complete (example: https://github.com/element-hq/element-x-android/actions/runs/9065756777): " runUrl
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue