Skip to content

Commit 46a2021

Browse files
committed
Add release workflow
1 parent 1e75b69 commit 46a2021

File tree

3 files changed

+235
-9
lines changed

3 files changed

+235
-9
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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()

.github/workflows/build.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
build_arduino:
1212
strategy:
13-
fail-fast: true
13+
fail-fast: false
1414
matrix:
1515
example:
1616
- "libraries/n-able/examples/FreeRTOS"
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030

3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v6
3333
- name: Set up Python
3434
uses: actions/setup-python@v5
3535
with:
@@ -44,14 +44,14 @@ jobs:
4444
with:
4545
cli-version: latest
4646
platforms: |
47-
- name: "h2zero:arm-ble"
47+
- name: "n-able-Arduino:arm-ble"
4848
source-url: "https://h2zero.github.io/n-able-Arduino/package_n-able_boards_index.json"
4949
version: latest
50-
- name: "h2zero:arm-ble"
50+
- name: "n-able-Arduino:arm-ble"
5151
source-path: .
5252
libraries: |
5353
- name: NimBLE-Arduino
54-
fqbn: "h2zero:arm-ble:${{ matrix.variant }}"
54+
fqbn: "n-able-Arduino:arm-ble:${{ matrix.variant }}"
5555
sketch-paths: ${{ matrix.example }}
5656

5757
build_pio:
@@ -70,18 +70,23 @@ jobs:
7070
- generic_nrf52840
7171
- adafruit_feather_nrf52840
7272
nimble_version:
73-
- release/1.4
73+
- release/2.3
7474
- master
7575
include:
7676
- example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server"
7777
flags: build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'
78+
- example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server"
79+
nimble_version: master
80+
flags: build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1'
7881
- variant: adafruit_feather_nrf52840
7982
bootloader: board_bootloader = adafruit
8083
exclude:
8184
- example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server"
8285
variant: generic_nrf51822_xxaa
8386
- example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server"
8487
variant: generic_nrf52832
88+
- example: "example/lib/examples/Bluetooth_5/NimBLE_extended_server"
89+
variant: generic_nrf52810
8590

8691
runs-on: ubuntu-latest
8792

@@ -92,7 +97,7 @@ jobs:
9297
mkdir example/src
9398
mkdir example/lib
9499
- name: Checkout n-able-arduino
95-
uses: actions/checkout@v4
100+
uses: actions/checkout@v6
96101
with:
97102
path: example/framework
98103
- name: Set up Python
@@ -104,7 +109,7 @@ jobs:
104109
python -m pip install --upgrade pip
105110
pip install platformio
106111
- name: Checkout NimBLE_Arduino
107-
uses: actions/checkout@v4
112+
uses: actions/checkout@v6
108113
with:
109114
repository: h2zero/NimBLE-Arduino
110115
ref: ${{ matrix.nimble_version }}
@@ -113,7 +118,7 @@ jobs:
113118
run: |
114119
cat > example/platformio.ini << EOF
115120
[env]
116-
platform = https://github.com/h2zero/platform-n-able.git@^1.0.0
121+
platform = https://github.com/h2zero/platform-n-able.git
117122
platform_packages = framework-n-able-arduino @ file://./framework
118123
framework = arduino
119124
${{ matrix.flags }}

.github/workflows/release.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Release tag (e.g., 6.6.6)'
10+
required: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout source
21+
uses: actions/checkout@v4
22+
23+
- name: Set version
24+
id: version
25+
run: |
26+
if [ "${{ github.event_name }}" == "release" ]; then
27+
VERSION=${{ github.event.release.tag_name }}
28+
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
29+
VERSION=${{ github.event.inputs.tag }}
30+
fi
31+
# Remove 'v' prefix if present
32+
VERSION=${VERSION#v}
33+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
34+
35+
- name: Create source archive
36+
id: archive
37+
run: |
38+
VERSION=${{ steps.version.outputs.version }}
39+
ARCHIVE_NAME="n-able-Arduino-${VERSION}.tar.gz"
40+
echo "Creating archive: ${ARCHIVE_NAME}"
41+
42+
# Temporarily disable exit on error for tar (it may return 1 if files change during archiving)
43+
set +e
44+
tar --warning=no-file-changed -czf "${ARCHIVE_NAME}" \
45+
--exclude=.git \
46+
--exclude=.github \
47+
--exclude=.gitignore \
48+
--exclude=.gitattributes \
49+
--exclude=node_modules \
50+
--exclude=build \
51+
--exclude=dist \
52+
--exclude='*.tar.gz' \
53+
--transform="s,^,n-able-Arduino-${VERSION}/," \
54+
.
55+
TAR_EXIT=$?
56+
set -e
57+
58+
# Tar exit codes: 0 = success, 1 = some files changed during archiving (but archive created)
59+
if [ $TAR_EXIT -gt 1 ]; then
60+
echo "Tar failed with exit code $TAR_EXIT"
61+
ls -la
62+
exit 1
63+
fi
64+
65+
# Calculate checksum and size
66+
echo "Files in directory:"
67+
ls -lh "${ARCHIVE_NAME}"
68+
CHECKSUM=$(sha256sum "${ARCHIVE_NAME}" | cut -d ' ' -f 1)
69+
if [ -f "${ARCHIVE_NAME}" ]; then
70+
SIZE=$(stat -c%s "${ARCHIVE_NAME}")
71+
else
72+
echo "Archive not created!"
73+
exit 1
74+
fi
75+
76+
echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
77+
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT
78+
echo "size=${SIZE}" >> $GITHUB_OUTPUT
79+
80+
- name: Checkout gh-pages
81+
uses: actions/checkout@v6
82+
with:
83+
ref: gh-pages
84+
path: gh-pages
85+
86+
- name: Update package index
87+
id: update-index
88+
env:
89+
VERSION: ${{ steps.version.outputs.version }}
90+
ARCHIVE_NAME: ${{ steps.archive.outputs.archive_name }}
91+
CHECKSUM: ${{ steps.archive.outputs.checksum }}
92+
SIZE: ${{ steps.archive.outputs.size }}
93+
run: |
94+
cd gh-pages
95+
python ../.github/scripts/update_package_index.py
96+
97+
- name: Commit and push to gh-pages
98+
working-directory: gh-pages
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
run: |
102+
git config user.name "github-actions"
103+
git config user.email "github-actions@github.com"
104+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
105+
git add package_n-able_boards_index.json
106+
git commit -m "Update package index for v${{ steps.version.outputs.version }}" || echo "No changes to commit"
107+
git push origin gh-pages

0 commit comments

Comments
 (0)