Skip to content

Commit bcb00e7

Browse files
committed
Add release workflow
1 parent 1e75b69 commit bcb00e7

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

.github/workflows/release.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release-wf
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: 'Release tag (e.g., 0.3.0)'
13+
required: true
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout source
24+
uses: actions/checkout@v4
25+
26+
- name: Set version
27+
id: version
28+
run: |
29+
if [ "${{ github.event_name }}" == "release" ]; then
30+
VERSION=${{ github.event.release.tag_name }}
31+
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
32+
VERSION=${{ github.event.inputs.tag }}
33+
else
34+
# For push events, use a test version
35+
VERSION="0.3.1-test"
36+
fi
37+
# Remove 'v' prefix if present
38+
VERSION=${VERSION#v}
39+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
40+
41+
- name: Create source archive
42+
id: archive
43+
run: |
44+
VERSION=${{ steps.version.outputs.version }}
45+
ARCHIVE_NAME="n-able-Arduino-${VERSION}.tar.gz"
46+
tar -czf "${ARCHIVE_NAME}" \
47+
--exclude=.git \
48+
--exclude=.github \
49+
--exclude=.gitignore \
50+
--exclude=node_modules \
51+
--exclude=build \
52+
--exclude=dist \
53+
--transform="s,^,n-able-Arduino-${VERSION}/," \
54+
.
55+
56+
# Calculate checksum and size
57+
CHECKSUM=$(sha256sum "${ARCHIVE_NAME}" | cut -d ' ' -f 1)
58+
SIZE=$(stat -f%z "${ARCHIVE_NAME}" 2>/dev/null || stat -c%s "${ARCHIVE_NAME}" 2>/dev/null)
59+
60+
echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
61+
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT
62+
echo "size=${SIZE}" >> $GITHUB_OUTPUT
63+
64+
- name: Checkout gh-pages
65+
uses: actions/checkout@v4
66+
with:
67+
ref: release-test
68+
path: gh-pages
69+
70+
- name: Update package index
71+
id: update-index
72+
env:
73+
VERSION: ${{ steps.version.outputs.version }}
74+
ARCHIVE_NAME: ${{ steps.archive.outputs.archive_name }}
75+
CHECKSUM: ${{ steps.archive.outputs.checksum }}
76+
SIZE: ${{ steps.archive.outputs.size }}
77+
run: |
78+
cd gh-pages
79+
80+
# Create Python script to update package index
81+
cat > update_index.py << 'EOF'
82+
import json
83+
import os
84+
import sys
85+
86+
version = os.environ.get('VERSION')
87+
archive_name = os.environ.get('ARCHIVE_NAME')
88+
checksum = os.environ.get('CHECKSUM')
89+
size = int(os.environ.get('SIZE'))
90+
91+
# Load existing package index
92+
with open('package_n-able_boards_index.json', 'r') as f:
93+
package_data = json.load(f)
94+
95+
# New platform entry
96+
new_platform = {
97+
"name": "Arm (Nim)BLE Boards",
98+
"architecture": "arm-ble",
99+
"version": version,
100+
"category": "Contributed",
101+
"help": {
102+
"online": "https://github.com/h2zero/n-able-Arduino/issues"
103+
},
104+
"url": f"https://github.com/h2zero/n-able-Arduino/archive/{version}.tar.gz",
105+
"archiveFileName": archive_name,
106+
"checksum": f"SHA-256:{checksum}",
107+
"size": str(size),
108+
"boards": [
109+
{"name": "Adafruit CLUE nRF52840"},
110+
{"name": "Adafruit Circuit Playground Bluefruit"},
111+
{"name": "Adafruit Feather nRF52832"},
112+
{"name": "Adafruit Feather nRF52840 Express"},
113+
{"name": "Adafruit Feather nRF52840 Sense"},
114+
{"name": "Adafruit ItsyBitsy nRF52840 Express"},
115+
{"name": "BBC micro:bit"},
116+
{"name": "BBC micro:bit v2"},
117+
{"name": "Bluz DK"},
118+
{"name": "Calliope mini"},
119+
{"name": "Ebyte E104-BT5032A-TB"},
120+
{"name": "Ebyte E104-BT5040UA Dongle"},
121+
{"name": "Electronut labs bluey"},
122+
{"name": "Electronut labs hackaBLE"},
123+
{"name": "Electronut labs hackaBLE v2"},
124+
{"name": "Generic nRF51822"},
125+
{"name": "Generic nRF52810"},
126+
{"name": "Generic nRF52832"},
127+
{"name": "Generic nRF52833"},
128+
{"name": "Generic nRF52840"},
129+
{"name": "ng-beacon"},
130+
{"name": "nRF51 Dongle"},
131+
{"name": "nRF51822 DK"},
132+
{"name": "nRF52832 DK"},
133+
{"name": "nRF52833 DK"},
134+
{"name": "nRF52840 DK"},
135+
{"name": "nRF52840 Dongle"},
136+
{"name": "Nordic Beacon Kit"},
137+
{"name": "OSHChip"},
138+
{"name": "RedBear BLE Nano"},
139+
{"name": "RedBear BLE Nano 2"},
140+
{"name": "RedBear Blend 2"},
141+
{"name": "RedBear nRF51822"},
142+
{"name": "Sino:bit"},
143+
{"name": "TinyBLE"},
144+
{"name": "Waveshare BLE400"},
145+
{"name": "Seeed XIAO nRF52840 Sense"}
146+
],
147+
"toolsDependencies": [
148+
{
149+
"packager": "h2zero",
150+
"name": "gcc-arm-none-eabi",
151+
"version": "9.3.1-1"
152+
},
153+
{
154+
"packager": "h2zero",
155+
"name": "openocd",
156+
"version": "0.11.0-4"
157+
}
158+
]
159+
}
160+
161+
# Check if version already exists and update or append
162+
found = False
163+
for platform in package_data['packages'][0]['platforms']:
164+
if platform['version'] == version:
165+
# Update existing version
166+
platform.update(new_platform)
167+
found = True
168+
break
169+
170+
if not found:
171+
# Append new version (maintaining reverse chronological order)
172+
package_data['packages'][0]['platforms'].insert(0, new_platform)
173+
174+
# Write updated package index
175+
with open('package_n-able_boards_index.json', 'w') as f:
176+
json.dump(package_data, f, indent=2)
177+
178+
print(f"Updated package index for version {version}")
179+
EOF
180+
181+
python update_index.py
182+
183+
- name: Commit and push to gh-pages
184+
working-directory: gh-pages
185+
env:
186+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187+
run: |
188+
git config user.name "github-actions"
189+
git config user.email "github-actions@github.com"
190+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
191+
git add package_n-able_boards_index.json
192+
git commit -m "Update package index for v${{ steps.version.outputs.version }}" || echo "No changes to commit"
193+
git push origin release-test

0 commit comments

Comments
 (0)