codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
243 stars 42 forks source link

Fix Google Play release promotion #361

Closed priitlatt closed 10 months ago

priitlatt commented 10 months ago

Fixes #360

There is a bug in codemagic.google_play.resources.Release initialization due to naive expectation in __post_init__ method that release notes are always passed as lists of dictionaries like they come from Google Play API responses. It should also be possible to initialize the object in case the notes are given with their expected target type List[LocalizedText].

One possible consequence of this is that duplicating release with notes fails with the following error:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/Users/priit/.pyenv/versions/3.12.0/lib/python3.12/dataclasses.py:1579: in replace
    return obj.__class__(**changes)
<string>:10: in __init__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Release(status=<ReleaseStatus.COMPLETED: 'completed'>, name='1.2.3', userFraction=None, countryTargeting={'countries':...ppUpdatePriority=None, versionCodes=['123'], releaseNotes=[LocalizedText(language='en-US', text='* Release\n\nnotes')])

    def __post_init__(self):
        if isinstance(self.releaseNotes, list):
>           self.releaseNotes = [LocalizedText(**note) for note in self.releaseNotes]
E           TypeError: codemagic.google_play.resources.track.LocalizedText() argument after ** must be a mapping, not LocalizedText

../../../src/codemagic/google_play/resources/track.py:60: TypeError

Update __post_init__ so that release notes that are already of type LocalizedText are left in place.

Updated actions: