@@ -142,30 +142,29 @@ def files(tar, path):
142142 return os .path .join (flatpak_tar_basedir , flatpak_deflated_dir )
143143
144144
145- def check_app_id_matches_flatpak (context , flatpak_path , channel ):
145+ def check_app_id_matches_flatpak (context , flatpak_path ):
146146 # Extract all ostree refs from the supplied Flatpak repo
147147 flatpak_refs = subprocess .check_output (["ostree" , "refs" ], cwd = flatpak_path ).decode ().splitlines ()
148148
149149 # Consolidate ostree refs into list of Flatpak IDs available in repo
150150 flatpak_refs = [ref .split ("/" )[1 ] for ref in flatpak_refs if ref .startswith ("app/" )]
151151
152+ app_id = task .get_flatpak_app_id (context .config , context .task )
153+
152154 # Create a list, if any, of all unexpected Flatpak IDs present in repo
153- invalid_refs = set (flatpak_refs ) - set ( context . config [ "app_ids" ]. values ())
155+ invalid_refs = set (flatpak_refs ) - app_id
154156
155- if context . config [ "app_ids" ][ channel ] not in flatpak_refs :
156- raise TaskVerificationError (f"Supplied app ID ({ context . config [ 'app_ids' ][ channel ] } ) is not present in Flatpak!" )
157+ if app_id not in flatpak_refs :
158+ raise TaskVerificationError (f"Supplied app ID ({ app_id } ) is not present in Flatpak!" )
157159
158160 if len (invalid_refs ) > 0 :
159161 raise TaskVerificationError ("One or more invalid app IDs are present in Flatpak!" )
160162
161163
162- def check_config_for_channel (config , channel ):
163- """Verify AppID and token location defined for supplied channel"""
164- if channel not in config ["app_ids" ]:
165- raise TaskVerificationError (f"Supplied channel ({ channel } ) does not have a configured appID" )
166-
167- if channel not in config ["token_locations" ]:
168- raise TaskVerificationError (f"Supplied channel ({ channel } ) does not have a configured token" )
164+ def check_config_for_branch (config , branch ):
165+ """Verify Token location defined for supplied branch"""
166+ if branch not in config ["token_locations" ]:
167+ raise TaskVerificationError (f"Supplied branch ({ branch } ) does not have a configured token" )
169168
170169
171170def sanitize_buildid (bytes_input ):
@@ -183,13 +182,14 @@ def push(context, flatpak_file_path, channel):
183182 # We don't raise an error because we still want green tasks on dev instances
184183 return
185184
186- check_config_for_channel (context .config , channel )
185+ branch = task .get_release_branch (context .config , context .task )
186+
187+ check_config_for_branch (context .config , branch )
187188
188- token_args = ["--token-file" , context .config ["token_locations" ][channel ]]
189+ token_args = ["--token-file" , context .config ["token_locations" ][branch ]]
189190 log .info ("Grab a flatpak buildid from Flathub ..." )
190- publish_channel = "beta" if channel == "beta" else "stable"
191191 publish_build_output = run_flat_manager_client_process (
192- context , token_args + ["create" , context .config ["flathub_url" ], publish_channel , "--build-log-url" , build_log ]
192+ context , token_args + ["create" , context .config ["flathub_url" ], channel , "--build-log-url" , build_log ]
193193 )
194194
195195 log .info ("Sanitize the buildid received from Flathub ..." )
@@ -203,7 +203,7 @@ def push(context, flatpak_file_path, channel):
203203 deflated_dir = check_and_extract_tar_archive (context , flatpak_file_path )
204204
205205 log .info ("Verifying supplied app ID matches flatpak app ID..." )
206- check_app_id_matches_flatpak (context , deflated_dir , channel )
206+ check_app_id_matches_flatpak (context , deflated_dir )
207207
208208 log .info (f"Pushing the flatpak to the associated { publish_build_output } " )
209209 run_flat_manager_client_process (context , token_args + ["push" , publish_build_output , deflated_dir ])
0 commit comments