From 46f03514e8b749e59d7b24dbd30407c7075dfcaf Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Thu, 11 Jul 2024 14:29:00 +0200 Subject: [PATCH 1/6] Revert "Reverted release.py script" This reverts commit bd7a5a0f1313078e7bc7f537b128bdd1ca753964. --- .github/scripts/release.py | 47 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/scripts/release.py b/.github/scripts/release.py index 392a95da..ca7351cd 100755 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -1,7 +1,7 @@ import argparse, copy, hashlib, json, re, requests, os, shutil -version = '0.1.0' +version = '0.2.0' xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir)) build_dir_name = 'pkg_build' @@ -60,20 +60,26 @@ def get_package_sha256(pkg): def get_latest_package_index_json(): return requests.get('https://github.com/Infineon/XMC-for-Arduino/releases/latest/download/package_infineon_index.json').json() +def get_local_package_index_json(): + with open(os.path.join(xmc_ino_root_path, 'package/package_infineon_index.template.json'), 'r') as f: + data = json.load(f) + return data + def get_platform_data_struct_copy(pkg_index): - return copy.deepcopy(pkg_index['packages'][0]['platforms'][0]) + return copy.deepcopy(pkg_index['packages'][0]['platforms']) -def set_new_platform_data_fields(platform_data, pkg_name, version): +def set_new_platform_data_fields(platform_data_index, pkg_name, version, repository): semver = strip_prefix_from_version(version) + platform_data = platform_data_index['packages'][0]['platforms'][0] platform_data['version'] = str(semver) archive_file_name = str(pkg_name) + ".zip" platform_data['archiveFileName'] = archive_file_name - platform_data['url'] = "https://github.com/Infineon/XMC-for-Arduino/releases/download/" + str(version) + "/" + str(archive_file_name) + platform_data['url'] = "https://github.com/" + str(repository) + "/releases/download/" + str(version) + "/" + str(archive_file_name) platform_data['checksum'] ="SHA-256:" + str(get_package_sha256(os.path.join(pkg_assets_build_path, archive_file_name))) platform_data['size'] = str(get_package_size(os.path.join(pkg_assets_build_path, archive_file_name))) -def add_new_platform_to_package_index(pkg_index, new_platform): - pkg_index['packages'][0]['platforms'].insert(0, new_platform) +def add_platform_to_package_index(pkg_index, platform): + pkg_index['packages'][0]['platforms'].insert(1, platform) def make_package_index_file(pkg_index): pkg_index_json_obj = json.dumps(pkg_index, indent=2) @@ -81,19 +87,27 @@ def make_package_index_file(pkg_index): with open(pkg_index_w_path, "w") as pkg_file: pkg_file.write(pkg_index_json_obj) -def build_package_index_json(pkg_name, version): - package_index = get_latest_package_index_json() - new_platform_data = get_platform_data_struct_copy(package_index) - set_new_platform_data_fields(new_platform_data, pkg_name, version) - add_new_platform_to_package_index(package_index, new_platform_data) - make_package_index_file(package_index) - -def build_release_assets(version): +def build_package_index_json(pkg_name, version, repository): + # get online package index json + latest_package_index = get_latest_package_index_json() + # get local package index template + local_package_index = get_local_package_index_json() + # set data field in local template for newest package + set_new_platform_data_fields(local_package_index, pkg_name, version, repository) + # get old package array + old_platform_data = get_platform_data_struct_copy(latest_package_index) + # append to local package index + add_platform_to_package_index(local_package_index, old_platform_data) + make_package_index_file(local_package_index) + +def build_release_assets(version, repository): + if os.path.exists(pkg_assets_build_path): + os.system("rm -rf "+pkg_assets_build_path) os.mkdir(pkg_assets_build_path) pkg_name = mkdir_package_dir(version) build_package(pkg_name) zip_package(pkg_name) - build_package_index_json(pkg_name, version) + build_package_index_json(pkg_name, version, repository) def parser(): @@ -105,7 +119,7 @@ def parser_build_release_assets_func(args): global pkg_build_path xmc_ino_root_path = args.root_path pkg_build_path = args.build_path - build_release_assets(args.version) + build_release_assets(args.version, args.repository) class ver_action(argparse.Action): def __init__(self, option_strings, dest, **kwargs): @@ -123,6 +137,7 @@ def __call__(self, parser, namespace, values, option_string, **kwargs): # Release parser parser_release = subparser.add_parser('build-release', description='Build package release assets') + parser_release.add_argument('repository', type=str, help='Repository name') parser_release.add_argument('version', type=str, help='Package release version (format: Vx.y.z)') parser_release.add_argument('-r','--root-path', type=str, default=xmc_ino_root_path, help='Path to the XMC-for-Arduino root path') parser_release.add_argument('-b','--build-path', type=str, default=pkg_assets_build_path, help='Path to build package') From dc6f5a0ef17a063738a54cbbbe2b85d25aa8f293 Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Thu, 11 Jul 2024 14:31:08 +0200 Subject: [PATCH 2/6] Revert "Reverted release.yml workflow." This reverts commit c2153776f2a5db91fe3e5baba426612aab164c8c. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31066b45..ecb094d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: - name: Build release assets run: | cd .github/scripts - python release.py build-release ${{ github.ref_name }} + python release.py build-release ${{ github.repository }} ${{ github.ref_name }} - name: Upload assets uses: softprops/action-gh-release@v1 From d837b9e178a40e4d097b74ee0a82bec88cc9466e Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Thu, 6 Jun 2024 18:36:25 +0200 Subject: [PATCH 3/6] fix release json generation script --- .github/scripts/release.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/release.py b/.github/scripts/release.py index ca7351cd..9729bfbb 100755 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -1,7 +1,7 @@ import argparse, copy, hashlib, json, re, requests, os, shutil -version = '0.2.0' +version = '0.2.1' xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir)) build_dir_name = 'pkg_build' @@ -79,7 +79,7 @@ def set_new_platform_data_fields(platform_data_index, pkg_name, version, reposit platform_data['size'] = str(get_package_size(os.path.join(pkg_assets_build_path, archive_file_name))) def add_platform_to_package_index(pkg_index, platform): - pkg_index['packages'][0]['platforms'].insert(1, platform) + pkg_index['packages'][0]['platforms'].extend(platform) def make_package_index_file(pkg_index): pkg_index_json_obj = json.dumps(pkg_index, indent=2) From 721d7279fda39c93bdd7263013f6db536e237cce Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Tue, 16 Jul 2024 10:13:49 +0200 Subject: [PATCH 4/6] FIx: change version of release script --- .github/scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/release.py b/.github/scripts/release.py index 9729bfbb..6a7f0dfc 100755 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -1,7 +1,7 @@ import argparse, copy, hashlib, json, re, requests, os, shutil -version = '0.2.1' +version = '0.2.0' xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir)) build_dir_name = 'pkg_build' From d54626dc66b7d156c8ff7da96a9f3f8f15e3d1a1 Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Tue, 16 Jul 2024 14:15:07 +0200 Subject: [PATCH 5/6] Fix: remove path using shutil --- .github/scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/release.py b/.github/scripts/release.py index 6a7f0dfc..969eb887 100755 --- a/.github/scripts/release.py +++ b/.github/scripts/release.py @@ -102,7 +102,7 @@ def build_package_index_json(pkg_name, version, repository): def build_release_assets(version, repository): if os.path.exists(pkg_assets_build_path): - os.system("rm -rf "+pkg_assets_build_path) + shutil.rmtree(pkg_assets_build_path) os.mkdir(pkg_assets_build_path) pkg_name = mkdir_package_dir(version) build_package(pkg_name) From bf74f0429adb622af3aabe0c567e1b189b8ef172 Mon Sep 17 00:00:00 2001 From: zhanglinjing Date: Tue, 16 Jul 2024 14:17:12 +0200 Subject: [PATCH 6/6] Docs: Remove xmc1400 2go content before release, fix one link problem --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 87b65bc8..32ea10de 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ This repository integrates [Infineon's](https://www.infineon.com/) XMC microcont * [XMC1100 2Go](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_2go_xmc1100_v1/) * [XMC1100 Boot Kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc11_boot_001/) * [XMC1300 Boot Kit](https://www.infineon.com/cms/de/product/evaluation-boards/kit_xmc13_boot_001/) -* [XMC1400 2Go (placeholder)]() * [XMC1400 Kit for Arduino](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc1400_arduino/) * [XMC4200 Platform 2Go](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_plt2go_xmc4200/) * [XMC4400 Platform 2Go](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_plt2go_xmc4400//) @@ -33,10 +32,9 @@ Please visit also the Wiki for additional information, e.g. datasheets, pin out [XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) -* Page for [XMC1100 XMC 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1100-2Go) +* Page for [XMC1100 XMC 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC-2Go) * Page for [XMC1100 Boot Kit](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1100-Boot-Kit) * Page for [XMC1300 Boot Kit](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1300-Boot-Kit) -* Page for [XMC1400 2Go (placeholder)](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1400-2Go) * Page for [XMC1400 Kit for Arduino](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1400-Kit-for-Arduino) * Page for [XMC4200 Platform 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC4200-Platform2Go) * Page for [XMC4400 Platform 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC4400-Platform2Go)