diff --git a/.github/scripts/update_package_index.py b/.github/scripts/update_package_index.py new file mode 100644 index 0000000..111ee7d --- /dev/null +++ b/.github/scripts/update_package_index.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 +""" +Update the Arduino board package index with a new release version. +""" +import json +import os +import sys + + +def main(): + version = os.environ.get('VERSION') + archive_name = os.environ.get('ARCHIVE_NAME') + checksum = os.environ.get('CHECKSUM') + size = os.environ.get('SIZE') + + if not all([version, archive_name, checksum, size]): + print("Error: Missing required environment variables") + print(f"VERSION={version}, ARCHIVE_NAME={archive_name}, CHECKSUM={checksum}, SIZE={size}") + sys.exit(1) + + # Load existing package index + with open('package_n-able_boards_index.json', 'r') as f: + package_data = json.load(f) + + # New platform entry + new_platform = { + "name": "Arm (Nim)BLE Boards", + "architecture": "arm-ble", + "version": version, + "category": "Contributed", + "help": { + "online": "https://github.com/h2zero/n-able-Arduino/issues" + }, + "url": f"https://github.com/h2zero/n-able-Arduino/archive/{version}.tar.gz", + "archiveFileName": archive_name, + "checksum": f"SHA-256:{checksum}", + "size": str(size), + "boards": [ + {"name": "Adafruit CLUE nRF52840"}, + {"name": "Adafruit Circuit Playground Bluefruit"}, + {"name": "Adafruit Feather nRF52832"}, + {"name": "Adafruit Feather nRF52840 Express"}, + {"name": "Adafruit Feather nRF52840 Sense"}, + {"name": "Adafruit ItsyBitsy nRF52840 Express"}, + {"name": "BBC micro:bit"}, + {"name": "BBC micro:bit v2"}, + {"name": "Bluz DK"}, + {"name": "Calliope mini"}, + {"name": "Ebyte E104-BT5032A-TB"}, + {"name": "Ebyte E104-BT5040UA Dongle"}, + {"name": "Electronut labs bluey"}, + {"name": "Electronut labs hackaBLE"}, + {"name": "Electronut labs hackaBLE v2"}, + {"name": "Generic nRF51822"}, + {"name": "Generic nRF52810"}, + {"name": "Generic nRF52832"}, + {"name": "Generic nRF52833"}, + {"name": "Generic nRF52840"}, + {"name": "ng-beacon"}, + {"name": "nRF51 Dongle"}, + {"name": "nRF51822 DK"}, + {"name": "nRF52832 DK"}, + {"name": "nRF52833 DK"}, + {"name": "nRF52840 DK"}, + {"name": "nRF52840 Dongle"}, + {"name": "Nordic Beacon Kit"}, + {"name": "OSHChip"}, + {"name": "RedBear BLE Nano"}, + {"name": "RedBear BLE Nano 2"}, + {"name": "RedBear Blend 2"}, + {"name": "RedBear nRF51822"}, + {"name": "Sino:bit"}, + {"name": "TinyBLE"}, + {"name": "Waveshare BLE400"}, + {"name": "Seeed XIAO nRF52840 Sense"} + ], + "toolsDependencies": [ + { + "packager": "h2zero", + "name": "gcc-arm-none-eabi", + "version": "9.3.1-1" + }, + { + "packager": "h2zero", + "name": "openocd", + "version": "0.11.0-4" + } + ] + } + + # Check if version already exists and update or append + found = False + for platform in package_data['packages'][0]['platforms']: + if platform['version'] == version: + # Update existing version + platform.update(new_platform) + found = True + print(f"Updated existing package index entry for version {version}") + break + + if not found: + # Append new version (maintaining reverse chronological order) + package_data['packages'][0]['platforms'].insert(0, new_platform) + print(f"Added new package index entry for version {version}") + + # Write updated package index + with open('package_n-able_boards_index.json', 'w') as f: + json.dump(package_data, f, indent=2) + + print(f"Successfully updated package index") + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a1f2d1..9472840 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: jobs: build_arduino: strategy: - fail-fast: true + fail-fast: false matrix: example: - "libraries/n-able/examples/FreeRTOS" @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python uses: actions/setup-python@v5 with: @@ -44,14 +44,14 @@ jobs: with: cli-version: latest platforms: | - - name: "h2zero:arm-ble" + - name: "n-able-Arduino:arm-ble" source-url: "https://h2zero.github.io/n-able-Arduino/package_n-able_boards_index.json" version: latest - - name: "h2zero:arm-ble" + - name: "n-able-Arduino:arm-ble" source-path: . libraries: | - name: NimBLE-Arduino - fqbn: "h2zero:arm-ble:${{ matrix.variant }}" + fqbn: "n-able-Arduino:arm-ble:${{ matrix.variant }}" sketch-paths: ${{ matrix.example }} build_pio: @@ -70,11 +70,14 @@ jobs: - generic_nrf52840 - adafruit_feather_nrf52840 nimble_version: - - release/1.4 + - release/2.3 - master include: - example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server" flags: build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + - example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server" + nimble_version: master + flags: build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' - variant: adafruit_feather_nrf52840 bootloader: board_bootloader = adafruit exclude: @@ -82,6 +85,8 @@ jobs: variant: generic_nrf51822_xxaa - example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server" variant: generic_nrf52832 + - example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server" + variant: generic_nrf52810 runs-on: ubuntu-latest @@ -92,7 +97,7 @@ jobs: mkdir example/src mkdir example/lib - name: Checkout n-able-arduino - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: example/framework - name: Set up Python @@ -104,7 +109,7 @@ jobs: python -m pip install --upgrade pip pip install platformio - name: Checkout NimBLE_Arduino - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: h2zero/NimBLE-Arduino ref: ${{ matrix.nimble_version }} @@ -113,7 +118,7 @@ jobs: run: | cat > example/platformio.ini << EOF [env] - platform = https://github.com/h2zero/platform-n-able.git@^1.0.0 + platform = https://github.com/h2zero/platform-n-able.git platform_packages = framework-n-able-arduino @ file://./framework framework = arduino ${{ matrix.flags }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7e1843a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,107 @@ +name: Release + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Release tag (e.g., 6.6.6)' + required: true + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set version + id: version + run: | + if [ "${{ github.event_name }}" == "release" ]; then + VERSION=${{ github.event.release.tag_name }} + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + VERSION=${{ github.event.inputs.tag }} + fi + # Remove 'v' prefix if present + VERSION=${VERSION#v} + echo "version=${VERSION}" >> $GITHUB_OUTPUT + + - name: Create source archive + id: archive + run: | + VERSION=${{ steps.version.outputs.version }} + ARCHIVE_NAME="n-able-Arduino-${VERSION}.tar.gz" + echo "Creating archive: ${ARCHIVE_NAME}" + + # Temporarily disable exit on error for tar (it may return 1 if files change during archiving) + set +e + tar --warning=no-file-changed -czf "${ARCHIVE_NAME}" \ + --exclude=.git \ + --exclude=.github \ + --exclude=.gitignore \ + --exclude=.gitattributes \ + --exclude=node_modules \ + --exclude=build \ + --exclude=dist \ + --exclude='*.tar.gz' \ + --transform="s,^,n-able-Arduino-${VERSION}/," \ + . + TAR_EXIT=$? + set -e + + # Tar exit codes: 0 = success, 1 = some files changed during archiving (but archive created) + if [ $TAR_EXIT -gt 1 ]; then + echo "Tar failed with exit code $TAR_EXIT" + ls -la + exit 1 + fi + + # Calculate checksum and size + echo "Files in directory:" + ls -lh "${ARCHIVE_NAME}" + CHECKSUM=$(sha256sum "${ARCHIVE_NAME}" | cut -d ' ' -f 1) + if [ -f "${ARCHIVE_NAME}" ]; then + SIZE=$(stat -c%s "${ARCHIVE_NAME}") + else + echo "Archive not created!" + exit 1 + fi + + echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT + echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT + echo "size=${SIZE}" >> $GITHUB_OUTPUT + + - name: Checkout gh-pages + uses: actions/checkout@v6 + with: + ref: gh-pages + path: gh-pages + + - name: Update package index + id: update-index + env: + VERSION: ${{ steps.version.outputs.version }} + ARCHIVE_NAME: ${{ steps.archive.outputs.archive_name }} + CHECKSUM: ${{ steps.archive.outputs.checksum }} + SIZE: ${{ steps.archive.outputs.size }} + run: | + cd gh-pages + python ../.github/scripts/update_package_index.py + + - name: Commit and push to gh-pages + working-directory: gh-pages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git + git add package_n-able_boards_index.json + git commit -m "Update package index for v${{ steps.version.outputs.version }}" || echo "No changes to commit" + git push origin gh-pages