Skip to content

Commit 15f2f8b

Browse files
committed
Add release workflow
1 parent 1e75b69 commit 15f2f8b

File tree

2 files changed

+214
-1
lines changed

2 files changed

+214
-1
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
-master
7-
pull_request:
7+
#pull_request:
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/release.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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+
echo "Creating archive: ${ARCHIVE_NAME}"
47+
48+
# Temporarily disable exit on error for tar (it may return 1 if files change during archiving)
49+
set +e
50+
tar --warning=no-file-changed -czf "${ARCHIVE_NAME}" \
51+
--exclude=.git \
52+
--exclude=.github \
53+
--exclude=.gitignore \
54+
--exclude=node_modules \
55+
--exclude=build \
56+
--exclude=dist \
57+
--transform="s,^,n-able-Arduino-${VERSION}/," \
58+
.
59+
TAR_EXIT=$?
60+
set -e
61+
62+
# Tar exit codes: 0 = success, 1 = some files changed during archiving (but archive created)
63+
if [ $TAR_EXIT -gt 1 ]; then
64+
echo "Tar failed with exit code $TAR_EXIT"
65+
ls -la
66+
exit 1
67+
fi
68+
69+
# Calculate checksum and size
70+
echo "Files in directory:"
71+
ls -lh "${ARCHIVE_NAME}"
72+
CHECKSUM=$(sha256sum "${ARCHIVE_NAME}" | cut -d ' ' -f 1)
73+
if [ -f "${ARCHIVE_NAME}" ]; then
74+
SIZE=$(stat -c%s "${ARCHIVE_NAME}")
75+
else
76+
echo "Archive not created!"
77+
exit 1
78+
fi
79+
80+
echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
81+
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT
82+
echo "size=${SIZE}" >> $GITHUB_OUTPUT
83+
84+
- name: Checkout gh-pages
85+
uses: actions/checkout@v4
86+
with:
87+
ref: release-test
88+
path: gh-pages
89+
90+
- name: Update package index
91+
id: update-index
92+
env:
93+
VERSION: ${{ steps.version.outputs.version }}
94+
ARCHIVE_NAME: ${{ steps.archive.outputs.archive_name }}
95+
CHECKSUM: ${{ steps.archive.outputs.checksum }}
96+
SIZE: ${{ steps.archive.outputs.size }}
97+
run: |
98+
cd gh-pages
99+
100+
# Create Python script to update package index
101+
cat > update_index.py << 'EOF'
102+
import json
103+
import os
104+
import sys
105+
106+
version = os.environ.get('VERSION')
107+
archive_name = os.environ.get('ARCHIVE_NAME')
108+
checksum = os.environ.get('CHECKSUM')
109+
size = int(os.environ.get('SIZE'))
110+
111+
# Load existing package index
112+
with open('package_n-able_boards_index.json', 'r') as f:
113+
package_data = json.load(f)
114+
115+
# New platform entry
116+
new_platform = {
117+
"name": "Arm (Nim)BLE Boards",
118+
"architecture": "arm-ble",
119+
"version": version,
120+
"category": "Contributed",
121+
"help": {
122+
"online": "https://github.com/h2zero/n-able-Arduino/issues"
123+
},
124+
"url": f"https://github.com/h2zero/n-able-Arduino/archive/{version}.tar.gz",
125+
"archiveFileName": archive_name,
126+
"checksum": f"SHA-256:{checksum}",
127+
"size": str(size),
128+
"boards": [
129+
{"name": "Adafruit CLUE nRF52840"},
130+
{"name": "Adafruit Circuit Playground Bluefruit"},
131+
{"name": "Adafruit Feather nRF52832"},
132+
{"name": "Adafruit Feather nRF52840 Express"},
133+
{"name": "Adafruit Feather nRF52840 Sense"},
134+
{"name": "Adafruit ItsyBitsy nRF52840 Express"},
135+
{"name": "BBC micro:bit"},
136+
{"name": "BBC micro:bit v2"},
137+
{"name": "Bluz DK"},
138+
{"name": "Calliope mini"},
139+
{"name": "Ebyte E104-BT5032A-TB"},
140+
{"name": "Ebyte E104-BT5040UA Dongle"},
141+
{"name": "Electronut labs bluey"},
142+
{"name": "Electronut labs hackaBLE"},
143+
{"name": "Electronut labs hackaBLE v2"},
144+
{"name": "Generic nRF51822"},
145+
{"name": "Generic nRF52810"},
146+
{"name": "Generic nRF52832"},
147+
{"name": "Generic nRF52833"},
148+
{"name": "Generic nRF52840"},
149+
{"name": "ng-beacon"},
150+
{"name": "nRF51 Dongle"},
151+
{"name": "nRF51822 DK"},
152+
{"name": "nRF52832 DK"},
153+
{"name": "nRF52833 DK"},
154+
{"name": "nRF52840 DK"},
155+
{"name": "nRF52840 Dongle"},
156+
{"name": "Nordic Beacon Kit"},
157+
{"name": "OSHChip"},
158+
{"name": "RedBear BLE Nano"},
159+
{"name": "RedBear BLE Nano 2"},
160+
{"name": "RedBear Blend 2"},
161+
{"name": "RedBear nRF51822"},
162+
{"name": "Sino:bit"},
163+
{"name": "TinyBLE"},
164+
{"name": "Waveshare BLE400"},
165+
{"name": "Seeed XIAO nRF52840 Sense"}
166+
],
167+
"toolsDependencies": [
168+
{
169+
"packager": "h2zero",
170+
"name": "gcc-arm-none-eabi",
171+
"version": "9.3.1-1"
172+
},
173+
{
174+
"packager": "h2zero",
175+
"name": "openocd",
176+
"version": "0.11.0-4"
177+
}
178+
]
179+
}
180+
181+
# Check if version already exists and update or append
182+
found = False
183+
for platform in package_data['packages'][0]['platforms']:
184+
if platform['version'] == version:
185+
# Update existing version
186+
platform.update(new_platform)
187+
found = True
188+
break
189+
190+
if not found:
191+
# Append new version (maintaining reverse chronological order)
192+
package_data['packages'][0]['platforms'].insert(0, new_platform)
193+
194+
# Write updated package index
195+
with open('package_n-able_boards_index.json', 'w') as f:
196+
json.dump(package_data, f, indent=2)
197+
198+
print(f"Updated package index for version {version}")
199+
EOF
200+
201+
python update_index.py
202+
203+
- name: Commit and push to gh-pages
204+
working-directory: gh-pages
205+
env:
206+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
207+
run: |
208+
git config user.name "github-actions"
209+
git config user.email "github-actions@github.com"
210+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
211+
git add package_n-able_boards_index.json
212+
git commit -m "Update package index for v${{ steps.version.outputs.version }}" || echo "No changes to commit"
213+
git push origin release-test

0 commit comments

Comments
 (0)