|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Update the Arduino board package index with a new release version. |
| 4 | +""" |
| 5 | +import json |
| 6 | +import os |
| 7 | +import sys |
| 8 | + |
| 9 | + |
| 10 | +def main(): |
| 11 | + version = os.environ.get('VERSION') |
| 12 | + archive_name = os.environ.get('ARCHIVE_NAME') |
| 13 | + checksum = os.environ.get('CHECKSUM') |
| 14 | + size = os.environ.get('SIZE') |
| 15 | + |
| 16 | + if not all([version, archive_name, checksum, size]): |
| 17 | + print("Error: Missing required environment variables") |
| 18 | + print(f"VERSION={version}, ARCHIVE_NAME={archive_name}, CHECKSUM={checksum}, SIZE={size}") |
| 19 | + sys.exit(1) |
| 20 | + |
| 21 | + # Load existing package index |
| 22 | + with open('package_n-able_boards_index.json', 'r') as f: |
| 23 | + package_data = json.load(f) |
| 24 | + |
| 25 | + # New platform entry |
| 26 | + new_platform = { |
| 27 | + "name": "Arm (Nim)BLE Boards", |
| 28 | + "architecture": "arm-ble", |
| 29 | + "version": version, |
| 30 | + "category": "Contributed", |
| 31 | + "help": { |
| 32 | + "online": "https://github.com/h2zero/n-able-Arduino/issues" |
| 33 | + }, |
| 34 | + "url": f"https://github.com/h2zero/n-able-Arduino/archive/{version}.tar.gz", |
| 35 | + "archiveFileName": archive_name, |
| 36 | + "checksum": f"SHA-256:{checksum}", |
| 37 | + "size": str(size), |
| 38 | + "boards": [ |
| 39 | + {"name": "Adafruit CLUE nRF52840"}, |
| 40 | + {"name": "Adafruit Circuit Playground Bluefruit"}, |
| 41 | + {"name": "Adafruit Feather nRF52832"}, |
| 42 | + {"name": "Adafruit Feather nRF52840 Express"}, |
| 43 | + {"name": "Adafruit Feather nRF52840 Sense"}, |
| 44 | + {"name": "Adafruit ItsyBitsy nRF52840 Express"}, |
| 45 | + {"name": "BBC micro:bit"}, |
| 46 | + {"name": "BBC micro:bit v2"}, |
| 47 | + {"name": "Bluz DK"}, |
| 48 | + {"name": "Calliope mini"}, |
| 49 | + {"name": "Ebyte E104-BT5032A-TB"}, |
| 50 | + {"name": "Ebyte E104-BT5040UA Dongle"}, |
| 51 | + {"name": "Electronut labs bluey"}, |
| 52 | + {"name": "Electronut labs hackaBLE"}, |
| 53 | + {"name": "Electronut labs hackaBLE v2"}, |
| 54 | + {"name": "Generic nRF51822"}, |
| 55 | + {"name": "Generic nRF52810"}, |
| 56 | + {"name": "Generic nRF52832"}, |
| 57 | + {"name": "Generic nRF52833"}, |
| 58 | + {"name": "Generic nRF52840"}, |
| 59 | + {"name": "ng-beacon"}, |
| 60 | + {"name": "nRF51 Dongle"}, |
| 61 | + {"name": "nRF51822 DK"}, |
| 62 | + {"name": "nRF52832 DK"}, |
| 63 | + {"name": "nRF52833 DK"}, |
| 64 | + {"name": "nRF52840 DK"}, |
| 65 | + {"name": "nRF52840 Dongle"}, |
| 66 | + {"name": "Nordic Beacon Kit"}, |
| 67 | + {"name": "OSHChip"}, |
| 68 | + {"name": "RedBear BLE Nano"}, |
| 69 | + {"name": "RedBear BLE Nano 2"}, |
| 70 | + {"name": "RedBear Blend 2"}, |
| 71 | + {"name": "RedBear nRF51822"}, |
| 72 | + {"name": "Sino:bit"}, |
| 73 | + {"name": "TinyBLE"}, |
| 74 | + {"name": "Waveshare BLE400"}, |
| 75 | + {"name": "Seeed XIAO nRF52840 Sense"} |
| 76 | + ], |
| 77 | + "toolsDependencies": [ |
| 78 | + { |
| 79 | + "packager": "h2zero", |
| 80 | + "name": "gcc-arm-none-eabi", |
| 81 | + "version": "9.3.1-1" |
| 82 | + }, |
| 83 | + { |
| 84 | + "packager": "h2zero", |
| 85 | + "name": "openocd", |
| 86 | + "version": "0.11.0-4" |
| 87 | + } |
| 88 | + ] |
| 89 | + } |
| 90 | + |
| 91 | + # Check if version already exists and update or append |
| 92 | + found = False |
| 93 | + for platform in package_data['packages'][0]['platforms']: |
| 94 | + if platform['version'] == version: |
| 95 | + # Update existing version |
| 96 | + platform.update(new_platform) |
| 97 | + found = True |
| 98 | + print(f"Updated existing package index entry for version {version}") |
| 99 | + break |
| 100 | + |
| 101 | + if not found: |
| 102 | + # Append new version (maintaining reverse chronological order) |
| 103 | + package_data['packages'][0]['platforms'].insert(0, new_platform) |
| 104 | + print(f"Added new package index entry for version {version}") |
| 105 | + |
| 106 | + # Write updated package index |
| 107 | + with open('package_n-able_boards_index.json', 'w') as f: |
| 108 | + json.dump(package_data, f, indent=2) |
| 109 | + |
| 110 | + print(f"Successfully updated package index") |
| 111 | + |
| 112 | + |
| 113 | +if __name__ == '__main__': |
| 114 | + main() |
0 commit comments