Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: rm APK_VERSION, and change versionCode calculation #9221

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

SomberNight
Copy link
Member

This drops the trailing .0 from the version number of android apks. It is a historical thing that we don't need/utilise anymore. (Some years ago, prior to reproducible builds at least, sometimes we had .1 and .2 releases just for android-specific bugs.)
Related #9210 (comment)

Also, the android versionCode calculation is changed to accommodate the changed version string, but also to have the architecture part in the least significant digits, as requested in #9210 (comment)

@thecockatiel Could you check if this looks good to you? (re version string and int version code construction)

Use our own logic to go from ELECTRUM_VERSION to numeric android versionCode,
instead of using the default conversion done by python-for-android.

Even before this, we were already patching p4a to modify their logic (see [0]).
This commit changes that logic again, and moves it into a separate script in our repo.
- calculation change is due to the f-droid maintainers asking for the
  arch code to be in the least significant digits (instead of most sig digits) (see [1])

I have pushed and changed to a new p4a branch, which is just a copy of the previous one
with 3 commits related to versionCode calc squashed.

[0]: SomberNight/python-for-android@edb7e4f
[1]: spesmilo#9210 (comment)
@thecockatiel
Copy link
Contributor

thecockatiel commented Sep 30, 2024

I'm not sure if offset is needed, we simply can make a major release (I know there's no breaking change, but it would help android versioning to be much simpler to reason about, and easier to predict). then first digit will be 5, which is higher than previously x86_64's 4:

def get_android_versioncode(*, arch_name: str) -> int:
    version_code = 0
    # add ELECTRUM_VERSION
    app_version = "5.0.0" # <--------------------------- added for testing
    app_version_components = app_version.split('.')
    assert len(app_version_components) == 3, f"version str expected to have 3 components, but got {app_version!r}"
    for i in app_version_components:
        version_code *= 100
        version_code += int(i)
    # add arch
    version_code *= 100
    arch_code = ARCH_DICT[arch_name]
    assert len(arch_code) == 1
    version_code *= 10
    version_code += int(arch_code)
    # note: up until version 4.5.5, we used a different scheme for version_code.
    #       4_______________4_05_05_00
    #       ^ android arch, ^ app_version (4.5.5.0)
    # legacy scheme is now compensated by a major release:
    # 44050500 ---> 50000004
    return version_code

# ^ android arch, ^ app_version (4.5.5.0)
# This offset ensures that all new-scheme version codes are larger than the old-scheme version codes.
offset_due_to_legacy_scheme = 45_000_000
version_code += offset_due_to_legacy_scheme
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if offset is needed, we simply can make a major release (I know there's no breaking change, but it would help android versioning to be much simpler to reason about, and easier to predict). then first digit will be 5, which is higher than previously x86_64's 4

As long as the major version number is a single digit (which will be true for the foreseeable future), this 45 million offset is equivalent to a simple "45" string prefix. I don't think that's too complicated.

I don't think we want to do a major version number bump just for this.

Copy link
Contributor

@thecockatiel thecockatiel Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, are you sure you don't want to put room for patch? if patch ever goes to two digits (ex, 4.5.10), it will fail.
currently for 4.5.5 it yields 45405054

Copy link
Contributor

@thecockatiel thecockatiel Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's actually fine, I ran some more examples and all looked fine to me, even though I thought it would not be fine.
4.1.50 -> 45401504
4.10.5 -> 45410054
4.10.50 -> 45410504
10.1.5 -> 46001054
10.10.50 -> 46010504

@thecockatiel
Copy link
Contributor

Also it would be nice if we could include the base version code in the git tag name, so it can be picked up by f-droid for VercodeOperation

@SomberNight
Copy link
Member Author

SomberNight commented Oct 1, 2024

include the base version code in the git tag name, so it can be picked up by f-droid for VercodeOperation

Do you mean having git tag names such as 4.5.5-45405050? I have not seen other projects doing that.
Why is that needed specifically?

I searched for VercodeOperation and found https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode but it's still not clear why we should put the full versionCode into the tag. Setting the tag to the version string should be just as good I think. (We have been naming git tags as basically ELECTRUM_VERSION (x.y.z) for some time. And now with this PR removing the APK_VERSION vs ELECTRUM_VERSION distinction, tags would directly correspond to apk version strings.)

Btw re release workflow, we typically push a git tag, and then start building binaries after. The build takes a long time and we also cross-compare it across multiple people doing builds (to check reproducibility) and only then upload them to the webserver. So the http links for a new version only become live ~1-2 days after a git tag is pushed.

@thecockatiel
Copy link
Contributor

thecockatiel commented Oct 1, 2024

hmmm, the delay could cause some issues, not necessarily as f-droid build cycles are like 7 days apart. the worst is it gets disabled until manually enabled through a MR again

about the version code. we need some way to either:

  1. take the version code directly from a file or tag name
  2. calculate it based on some number

the issue is this specifically: https://gitlab.com/fdroid/fdroidserver/-/issues/1228
until they give us a way to turn the dot separated numbers into a single number, it's not possible

@thecockatiel
Copy link
Contributor

@SomberNight
Copy link
Member Author

SomberNight commented Oct 1, 2024

Well there is https://electrum.org/version. It is a json file.
It is used by the desktop gui to check for updates, so this file is guaranteed to only be updated once binaries are available on download.electrum.org.


EDIT: would it solve this if we put the "base" versionCode into that json file?
note: we were considering extending that json file already in #8311

@SomberNight
Copy link
Member Author

Well there is https://electrum.org/version. It is a json file.

It is also available in the website git repo btw, along with the rest of the website:
https://github.com/spesmilo/electrum-web/blob/master/version

It is generated as part of the release process, in contrib/release_www.sh. There we could call get_apk_versioncode.py for e.g. the "null" arch, and put that base versionCode somewhere into the version json file.

@SomberNight
Copy link
Member Author

Re this PR in particular, if there are no objections (?), I will merge it.

@thecockatiel
Copy link
Contributor

thecockatiel commented Oct 1, 2024

Re this PR in particular, if there are no objections (?), I will merge it.

LGTM

https://github.com/spesmilo/electrum-web/blob/master/version

the problem is the time lag makes it difficult, as I don't know when f-droid will try to access the url and the binaries. if f-droid picks up the tag before the release & version update, the version code extracted from the file will be out dated and invalid. maybe f-droid retries ? we have to ask to know if we can use it. but sounds good overall.

edit: I saw that there's a HTTP check mode (I just saw the docs for it), so it's gonna be fine. putting the versionCode in there is gonna work out pretty well I think

@SomberNight SomberNight merged commit 76bed23 into spesmilo:master Oct 2, 2024
15 checks passed
SomberNight added a commit to SomberNight/electrum that referenced this pull request Oct 7, 2024
This can be used by the F-Droid buildserver to detect new versions
and release updates automatically.

ref:
spesmilo#9221 (comment)
https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
SomberNight added a commit to SomberNight/electrum that referenced this pull request Oct 7, 2024
This can be used by the F-Droid buildserver to detect new versions
and release updates automatically.

ref:
spesmilo#9221 (comment)
https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
SomberNight added a commit to SomberNight/electrum that referenced this pull request Oct 7, 2024
This can be used by the F-Droid buildserver to detect new versions
and release updates automatically.

ref:
spesmilo#9221 (comment)
https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
SomberNight added a commit that referenced this pull request Oct 14, 2024
This can be used by the F-Droid buildserver to detect new versions
and release updates automatically.

ref:
#9221 (comment)
https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants