Skip to content

Commit 7ea2867

Browse files
committed
on_release: allow single board packages
1 parent c45c9c6 commit 7ea2867

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Diff for: .github/scripts/on-release.sh

+27-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPA
3636
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
3737
echo "Tag: $RELEASE_TAG, Draft: $draft, Pre-Release: $RELEASE_PRE"
3838

39+
# Try extracting something like a JSON with a "boards" array/element and "vendor" fields
40+
BOARDS=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.boards[]? // .boards? // empty' | xargs echo -n 2>/dev/null`
41+
VENDOR=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.vendor? // empty' | xargs echo -n 2>/dev/null`
42+
if ! [ -z "${BOARDS}" ]; then echo "Releasing board(s): $BOARDS" ; fi
43+
if ! [ -z "${VENDOR}" ]; then echo "Setting packager: $VENDOR" ; fi
44+
3945
function get_file_size(){
4046
local file="$1"
4147
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -171,12 +177,26 @@ mkdir -p "$PKG_DIR/tools"
171177

172178
# Copy all core files to the package folder
173179
echo "Copying files for packaging ..."
174-
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
180+
if [ -z "${BOARDS}" ]; then
181+
# Copy all variants
182+
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
183+
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
184+
else
185+
# Remove all entries not starting with any board code or "menu." from boards.txt
186+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^menu\." > "$PKG_DIR/boards.txt"
187+
for board in ${BOARDS} ; do
188+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^${board}\." >> "$PKG_DIR/boards.txt"
189+
done
190+
# Copy only relevant variant files
191+
mkdir "$PKG_DIR/variants/"
192+
for variant in `cat ${PKG_DIR}/boards.txt | grep "\.variant=" | cut -d= -f2` ; do
193+
cp -Rf "$GITHUB_WORKSPACE/variants/${variant}" "$PKG_DIR/variants/"
194+
done
195+
fi
175196
cp -f "$GITHUB_WORKSPACE/package.json" "$PKG_DIR/"
176197
cp -f "$GITHUB_WORKSPACE/programmers.txt" "$PKG_DIR/"
177198
cp -Rf "$GITHUB_WORKSPACE/cores" "$PKG_DIR/"
178199
cp -Rf "$GITHUB_WORKSPACE/libraries" "$PKG_DIR/"
179-
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
180200
cp -f "$GITHUB_WORKSPACE/tools/espota.exe" "$PKG_DIR/tools/"
181201
cp -f "$GITHUB_WORKSPACE/tools/espota.py" "$PKG_DIR/tools/"
182202
cp -f "$GITHUB_WORKSPACE/tools/gen_esp32part.py" "$PKG_DIR/tools/"
@@ -209,6 +229,11 @@ sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-
209229
sed 's/debug.server.openocd.scripts_dir.windows={runtime.platform.path}\\tools\\openocd-esp32\\share\\openocd\\scripts\\/debug.server.openocd.scripts_dir.windows=\{runtime.tools.openocd-esp32.path\}\\share\\openocd\\scripts\\/g' \
210230
> "$PKG_DIR/platform.txt"
211231

232+
if ! [ -z ${VENDOR} ]; then
233+
# Append vendor name to platform.txt to create a separate section
234+
sed -i "/^name=.*/s/$/ ($VENDOR)/" "$PKG_DIR/platform.txt"
235+
fi
236+
212237
# Add header with version information
213238
echo "Generating core_version.h ..."
214239
ver_define=`echo $RELEASE_TAG | tr "[:lower:].\055" "[:upper:]_"`

0 commit comments

Comments
 (0)