-
Notifications
You must be signed in to change notification settings - Fork 17
198 lines (178 loc) · 7.06 KB
/
Copy pathrelease.yml
File metadata and controls
198 lines (178 loc) · 7.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Release
on:
push:
branches:
- release-wf
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., 0.3.0)'
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 }}
else
# For push events, use a test version
VERSION="0.3.1-test"
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"
tar --warning=no-file-changed -czf "${ARCHIVE_NAME}" \
--exclude=.git \
--exclude=.github \
--exclude=.gitignore \
--exclude=node_modules \
--exclude=build \
--exclude=dist \
--transform="s,^,n-able-Arduino-${VERSION}/," \
.
# Calculate checksum and size
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@v4
with:
ref: release-test
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
# Create Python script to update package index
cat > update_index.py << 'EOF'
import json
import os
import sys
version = os.environ.get('VERSION')
archive_name = os.environ.get('ARCHIVE_NAME')
checksum = os.environ.get('CHECKSUM')
size = int(os.environ.get('SIZE'))
# 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
break
if not found:
# Append new version (maintaining reverse chronological order)
package_data['packages'][0]['platforms'].insert(0, new_platform)
# Write updated package index
with open('package_n-able_boards_index.json', 'w') as f:
json.dump(package_data, f, indent=2)
print(f"Updated package index for version {version}")
EOF
python update_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 release-test