@@ -453,6 +453,7 @@ def package_card_files(repo_root, files_root_dir, path_list, sdk_version):
453
453
os .path .join (repo_root , f'tmp/assets/{ asset_type } /{ each_query_path } ' ),
454
454
os .path .join (repo_root , f'tmp/assets/{ asset_type } /{ package_name } .7z' )
455
455
)
456
+ os .chdir (repo_root )
456
457
query_file = '\' {"package":"' + package_name + '"}\' '
457
458
archive_list .update (
458
459
{
@@ -485,6 +486,20 @@ def fetch_live_packages(url):
485
486
os .remove (os .path .join (os .path .dirname (__file__ ), os .path .basename (url )))
486
487
return metadata_json ['packages' ], metadata_json
487
488
489
+ def fetch_previous_asset_hash (release , asset_name , new_dir_hash ):
490
+ previous_hash = None
491
+ for each_asset in release ['assets' ]:
492
+ if each_asset ['name' ] == f'{ asset_name } .7z' :
493
+ support .extract_archive_from_url (
494
+ each_asset ['url' ], os .path .join (os .getcwd (), 'tmp/temp_asset' ), args .token
495
+ )
496
+ previous_hash = hash_directory_contents (os .path .join (os .getcwd (), 'tmp/temp_asset' ))
497
+ shutil .rmtree (os .path .join (os .getcwd (), 'tmp/temp_asset' ))
498
+ break
499
+ current_hash = hash_directory_contents (new_dir_hash )
500
+
501
+ return previous_hash , current_hash
502
+
488
503
if __name__ == '__main__' :
489
504
# First, check for arguments passed
490
505
def str2bool (v ):
@@ -519,6 +534,9 @@ def str2bool(v):
519
534
# Get the release ID used to upload assets
520
535
release_id = get_release_id (args .repo , f'mikroSDK-{ version } ' , args .token )
521
536
537
+ # Get the full release details
538
+ release = fetch_release_details (args .repo , args .token , 'latest' )
539
+
522
540
metadata_content = {}
523
541
if not args .package_boards_or_mcus :
524
542
if manifest_folder :
@@ -534,19 +552,9 @@ def str2bool(v):
534
552
print ('Asset "%s" uploaded successfully to release ID/Tag name: %s / %s' % ('mikrosdk' , release_id , release ['tag_name' ]))
535
553
536
554
if os .path .exists (os .path .join (repo_dir , 'resources/images' )):
537
- release = fetch_release_details (args .repo , args .token , 'latest' )
538
- previous_images_hash = None
539
- for each_asset in release ['assets' ]:
540
- if each_asset ['name' ] == 'images.7z' :
541
- support .extract_archive_from_url (
542
- each_asset ['url' ], os .path .join (os .getcwd (), 'tmp/images_asset' ), args .token
543
- )
544
- previous_images_hash = hash_directory_contents (os .path .join (os .getcwd (), 'tmp/images_asset' ))
545
- shutil .rmtree (os .path .join (os .getcwd (), 'tmp/images_asset' ))
546
- break
547
- current_image_hash = hash_directory_contents (os .path .join (os .getcwd (), 'resources/images' ))
548
- metadata_content ['images' ] = {'hash' : current_image_hash }
549
- if current_image_hash != previous_images_hash :
555
+ previous_hash , current_hash = fetch_previous_asset_hash (release , 'images' , os .path .join (os .getcwd (), 'resources/images' ))
556
+ metadata_content ['images' ] = {'hash' : current_hash }
557
+ if current_hash != previous_hash :
550
558
archive_path = os .path .join (repo_dir , 'images.7z' )
551
559
print ('Creating archive: %s' % archive_path )
552
560
create_custom_archive ('resources/images' , archive_path )
@@ -559,11 +567,13 @@ def str2bool(v):
559
567
560
568
if not args .package_boards_or_mcus :
561
569
if os .path .exists (os .path .join (repo_dir , 'templates/necto' )):
570
+ previous_hash , current_hash = fetch_previous_asset_hash (release , 'templates' , os .path .join (os .getcwd (), 'resources/templates' ))
571
+ metadata_content ['templates' ] = {'hash' : current_hash }
572
+ if current_hash != previous_hash :
562
573
archive_path = os .path .join (repo_dir , 'templates.7z' )
563
574
print ('Creating archive: %s' % archive_path )
564
575
create_custom_archive ('templates/necto' , archive_path )
565
576
os .chdir (repo_dir )
566
- metadata_content ['templates' ] = {'hash' : hash_directory_contents (os .path .join (repo_dir , 'templates/necto' ))}
567
577
print ('Archive created successfully: %s' % archive_path )
568
578
upload_result = upload_asset_to_release (args .repo , release_id , archive_path , args .token )
569
579
print ('Asset "%s" uploaded successfully to release ID/Tag name: %s / %s' % ('templates' , release_id , release ['tag_name' ]))
@@ -614,7 +624,7 @@ def str2bool(v):
614
624
if args .package_boards_or_mcus :
615
625
execute = True
616
626
for each_metadata_package in live_packages :
617
- if live_packages [each_metadata_package ]['name ' ] == current_package_data ['name ' ]:
627
+ if live_packages [each_metadata_package ]['display_name ' ] == current_package_data ['display_name ' ]:
618
628
# If package has been changed, update it either way
619
629
if current_package_data ['hash' ] == live_packages [each_metadata_package ]['hash' ]:
620
630
execute = False
0 commit comments