Skip to content

Commit bed41f4

Browse files
authored
Merge pull request #290 from Infineon/develop
update release process
2 parents bb7c3d4 + f52f7b6 commit bed41f4

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

.github/scripts/release.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import argparse, copy, hashlib, json, re, requests, os, shutil
33

4-
version = '0.1.0'
4+
version = '0.2.0'
55

66
xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir))
77
build_dir_name = 'pkg_build'
@@ -60,40 +60,54 @@ def get_package_sha256(pkg):
6060
def get_latest_package_index_json():
6161
return requests.get('https://github.com/Infineon/XMC-for-Arduino/releases/latest/download/package_infineon_index.json').json()
6262

63+
def get_local_package_index_json():
64+
with open(os.path.join(xmc_ino_root_path, 'package/package_infineon_index.template.json'), 'r') as f:
65+
data = json.load(f)
66+
return data
67+
6368
def get_platform_data_struct_copy(pkg_index):
64-
return copy.deepcopy(pkg_index['packages'][0]['platforms'][0])
69+
return copy.deepcopy(pkg_index['packages'][0]['platforms'])
6570

66-
def set_new_platform_data_fields(platform_data, pkg_name, version):
71+
def set_new_platform_data_fields(platform_data_index, pkg_name, version, repository):
6772
semver = strip_prefix_from_version(version)
73+
platform_data = platform_data_index['packages'][0]['platforms'][0]
6874
platform_data['version'] = str(semver)
6975
archive_file_name = str(pkg_name) + ".zip"
7076
platform_data['archiveFileName'] = archive_file_name
71-
platform_data['url'] = "https://github.com/Infineon/XMC-for-Arduino/releases/download/" + str(version) + "/" + str(archive_file_name)
77+
platform_data['url'] = "https://github.com/" + str(repository) + "/releases/download/" + str(version) + "/" + str(archive_file_name)
7278
platform_data['checksum'] ="SHA-256:" + str(get_package_sha256(os.path.join(pkg_assets_build_path, archive_file_name)))
7379
platform_data['size'] = str(get_package_size(os.path.join(pkg_assets_build_path, archive_file_name)))
7480

75-
def add_new_platform_to_package_index(pkg_index, new_platform):
76-
pkg_index['packages'][0]['platforms'].insert(0, new_platform)
81+
def add_platform_to_package_index(pkg_index, platform):
82+
pkg_index['packages'][0]['platforms'].extend(platform)
7783

7884
def make_package_index_file(pkg_index):
7985
pkg_index_json_obj = json.dumps(pkg_index, indent=2)
8086
pkg_index_w_path = os.path.join(pkg_assets_build_path, "package_infineon_index.json")
8187
with open(pkg_index_w_path, "w") as pkg_file:
8288
pkg_file.write(pkg_index_json_obj)
8389

84-
def build_package_index_json(pkg_name, version):
85-
package_index = get_latest_package_index_json()
86-
new_platform_data = get_platform_data_struct_copy(package_index)
87-
set_new_platform_data_fields(new_platform_data, pkg_name, version)
88-
add_new_platform_to_package_index(package_index, new_platform_data)
89-
make_package_index_file(package_index)
90-
91-
def build_release_assets(version):
90+
def build_package_index_json(pkg_name, version, repository):
91+
# get online package index json
92+
latest_package_index = get_latest_package_index_json()
93+
# get local package index template
94+
local_package_index = get_local_package_index_json()
95+
# set data field in local template for newest package
96+
set_new_platform_data_fields(local_package_index, pkg_name, version, repository)
97+
# get old package array
98+
old_platform_data = get_platform_data_struct_copy(latest_package_index)
99+
# append to local package index
100+
add_platform_to_package_index(local_package_index, old_platform_data)
101+
make_package_index_file(local_package_index)
102+
103+
def build_release_assets(version, repository):
104+
if os.path.exists(pkg_assets_build_path):
105+
shutil.rmtree(pkg_assets_build_path)
92106
os.mkdir(pkg_assets_build_path)
93107
pkg_name = mkdir_package_dir(version)
94108
build_package(pkg_name)
95109
zip_package(pkg_name)
96-
build_package_index_json(pkg_name, version)
110+
build_package_index_json(pkg_name, version, repository)
97111

98112
def parser():
99113

@@ -105,7 +119,7 @@ def parser_build_release_assets_func(args):
105119
global pkg_build_path
106120
xmc_ino_root_path = args.root_path
107121
pkg_build_path = args.build_path
108-
build_release_assets(args.version)
122+
build_release_assets(args.version, args.repository)
109123

110124
class ver_action(argparse.Action):
111125
def __init__(self, option_strings, dest, **kwargs):
@@ -123,6 +137,7 @@ def __call__(self, parser, namespace, values, option_string, **kwargs):
123137

124138
# Release parser
125139
parser_release = subparser.add_parser('build-release', description='Build package release assets')
140+
parser_release.add_argument('repository', type=str, help='Repository name')
126141
parser_release.add_argument('version', type=str, help='Package release version (format: Vx.y.z)')
127142
parser_release.add_argument('-r','--root-path', type=str, default=xmc_ino_root_path, help='Path to the XMC-for-Arduino root path')
128143
parser_release.add_argument('-b','--build-path', type=str, default=pkg_assets_build_path, help='Path to build package')

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Build release assets
2828
run: |
2929
cd .github/scripts
30-
python release.py build-release ${{ github.ref_name }}
30+
python release.py build-release ${{ github.repository }} ${{ github.ref_name }}
3131
3232
- name: Upload assets
3333
uses: softprops/action-gh-release@v1

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ This repository integrates [Infineon's](https://www.infineon.com/) XMC microcont
2121
* [XMC1100 2Go](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_2go_xmc1100_v1/)
2222
* [XMC1100 Boot Kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc11_boot_001/)
2323
* [XMC1300 Boot Kit](https://www.infineon.com/cms/de/product/evaluation-boards/kit_xmc13_boot_001/)
24-
* [XMC1400 2Go (placeholder)]()
2524
* [XMC1400 Kit for Arduino](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc1400_arduino/)
2625
* [XMC4200 Platform 2Go](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_plt2go_xmc4200/)
2726
* [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
3332

3433
[XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki)
3534

36-
* Page for [XMC1100 XMC 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1100-2Go)
35+
* Page for [XMC1100 XMC 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC-2Go)
3736
* Page for [XMC1100 Boot Kit](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1100-Boot-Kit)
3837
* Page for [XMC1300 Boot Kit](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1300-Boot-Kit)
39-
* Page for [XMC1400 2Go (placeholder)](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1400-2Go)
4038
* Page for [XMC1400 Kit for Arduino](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC1400-Kit-for-Arduino)
4139
* Page for [XMC4200 Platform 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC4200-Platform2Go)
4240
* Page for [XMC4400 Platform 2Go](https://github.com/Infineon/XMC-for-Arduino/wiki/XMC4400-Platform2Go)

0 commit comments

Comments
 (0)