Skip to content

Commit 246a6d1

Browse files
facchinmpillo79
authored andcommitted
on_release: allow single board packages
1 parent 272a0a5 commit 246a6d1

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

.github/scripts/on-release.sh

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

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

171177
# Copy all core files to the package folder
172178
echo "Copying files for packaging ..."
173-
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
179+
if [ -z "${BOARDS}" ]; then
180+
# Copy all variants
181+
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
182+
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
183+
else
184+
# Remove all entries not starting with any board code or "menu." from boards.txt
185+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^menu\." > "$PKG_DIR/boards.txt"
186+
for board in ${BOARDS} ; do
187+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^${board}\." >> "$PKG_DIR/boards.txt"
188+
done
189+
# Copy only relevant variant files
190+
mkdir "$PKG_DIR/variants/"
191+
for variant in `cat ${PKG_DIR}/boards.txt | grep "\.variant=" | cut -d= -f2` ; do
192+
cp -Rf "$GITHUB_WORKSPACE/variants/${variant}" "$PKG_DIR/variants/"
193+
done
194+
fi
174195
cp -f "$GITHUB_WORKSPACE/package.json" "$PKG_DIR/"
175196
cp -f "$GITHUB_WORKSPACE/programmers.txt" "$PKG_DIR/"
176197
cp -Rf "$GITHUB_WORKSPACE/cores" "$PKG_DIR/"
177198
cp -Rf "$GITHUB_WORKSPACE/libraries" "$PKG_DIR/"
178-
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
179199
cp -f "$GITHUB_WORKSPACE/tools/espota.exe" "$PKG_DIR/tools/"
180200
cp -f "$GITHUB_WORKSPACE/tools/espota.py" "$PKG_DIR/tools/"
181201
cp -f "$GITHUB_WORKSPACE/tools/gen_esp32part.py" "$PKG_DIR/tools/"
@@ -212,6 +232,11 @@ sed 's/{runtime\.platform\.path}.tools.esptool/\{runtime.tools.esptool_py.path\}
212232
sed 's/{runtime\.platform\.path}.tools.openocd-esp32/\{runtime.tools.openocd-esp32.path\}/g' \
213233
> "$PKG_DIR/platform.txt"
214234

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

0 commit comments

Comments
 (0)