thunderbird / thunderbird-android

Thunderbird for Android – Open Source Email App for Android (fka K-9 Mail)
https://thunderbird.net/mobile
Apache License 2.0
10.91k stars 2.51k forks source link

VersionCode should be autogenerated to ease release automation #7616

Open wmontwe opened 9 months ago

wmontwe commented 9 months ago

To streamline our release automation process, it would be beneficial to implement an automatic version code generation strategy rather than relying on manual updates.

Reviewing the Firefox for Android project, I found they use a date-based system for generating a unique and sequentially increasing versionCode. Their method utilizes the format yDDDHHmm, where:

This approach stays within the maximum allowed versionCode of 2,100,000,000, typically producing a 9-digit code, ensuring each version is unique and sequentially higher than the last.

I propose we adopt a similar, date-based calculation for our version code, incorporating the same format yDDDHHmm:

For example:

Alternatively the format ymmmmmm, with even more head room but harder to read:

This alternative approach would generate:

I welcome any feedback or suggestions on these proposed methods.

ByteHamster commented 9 months ago

I think this might cause problems with F-Droid releases. I think they parse gradle files manually and if it's not a constant, they can't do that.

wmontwe commented 9 months ago

Right, F-Droid expects a static version code. So, if we write the version code to a file and the release build is picking that up, it should be fine. I guess we also need to commit this file for reproducible builds.

wmontwe commented 9 months ago

We could also use prebuild to inject the desired date before building.

cketti commented 9 months ago

Is it really necessary to have a versionCode scheme based on the date? Can't we just have a script increment the version code for every release?

wmontwe commented 8 months ago

It eliminates the need to do manual versionCode changes. Otherwise any automation needs manual intervention or an self update. I'm not a fan of allowing CI workflows to commit code.

wmontwe commented 8 months ago

A total different approach is to derive the version code from a git tag. But that is usually more complicated.

scollovati commented 7 months ago

Currently in F-Droid all the metadata and release notes/changelog have disappeared: https://f-droid.org/en/packages/com.fsck.k9/

EDIT: Found the deedicated issue here https://github.com/thunderbird/thunderbird-android/issues/7709#issue-2179118986

abdoughnut commented 7 months ago

If you wanted, rather than using a git tag, you can simply count the number of commits as the version code. Something like git rev-list --first-parent --count origin/main here's a sample you could add in the gradle file.

val getVersionCode: () -> Int = {
    try {
        val stdout = ByteArrayOutputStream()
        exec {
            commandLine("git", "rev-list", "--first-parent", "--count", "origin/main")
            standardOutput = stdout
        }
        stdout.toString().trim().toInt()
    } catch (ignored: Exception) {
        -1
    }
}
kewisch commented 2 weeks ago

We're going to move forward on this since we need to generate a version code for daily builds. cketti Wolf and I talked about this and we're moving forward with the date based approach.

We should put the version code into a properties file so that we can easily keep the version code the same across channels, while bumping the version name according to branch on merge day.

Noting for the record that with Wolf's first approach our maximum version code is 2093662359, which would mean we are safe until 2232. If email survives that long I think we're good :-)

kewisch commented 2 weeks ago

There will not be a commit for each daily build, but we won't be doing daily builds on f-droid. Beta and Release builds will continue to increment by 1 where we do have the version bumps in commits. We could argue that for consistency we can use the same date based version code approach on beta/release, but since we already have a bump system now I think we could continue as is until we run into problems.