Skip to content

Commit 0ccd765

Browse files
committed
package_core: fix GitHub Actions logging syntax
Use a common function to handle logging messages for GitHub Actions and for the console, for a cleaner output. Signed-off-by: Luca Burelli <[email protected]> :1
1 parent 1fc608b commit 0ccd765

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

extra/package_core.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ ARTIFACT=$1
1616
VERSION=$2
1717
OUTPUT_FILE=${3:-distrib/${ARTIFACT}-${VERSION}.tar.bz2}
1818

19+
log_msg() {
20+
if [ -n $GITHUB_WORKSPACE ] ; then
21+
echo "::$1::$2"
22+
else
23+
echo "$2"
24+
fi
25+
}
26+
1927
# we use variants for include because we filter on file paths
2028
# and boards for exclude because we want to remove matching lines in boards.txt
2129
BOARD_DETAILS=$(extra/get_board_details.sh)
@@ -31,7 +39,7 @@ else
3139
EXCLUDED_BOARDS=$(echo ${BOARD_DETAILS} | jq -cr "map(select(.artifact != \"$ARTIFACT\")) | .[].board")
3240
fi
3341

34-
[ -n $GITHUB_WORKSPACE ] && echo "::group::Packaging ${ARTIFACT_NAME:-all variants} ($(basename $OUTPUT_FILE))"
42+
log_msg group "Packaging ${ARTIFACT_NAME:-all variants} ($(basename $OUTPUT_FILE))"
3543

3644
# create a temporary boards.txt file with the correct list of boards
3745
TEMP_BOARDS=$(mktemp -p . | sed 's/\.\///')
@@ -50,6 +58,7 @@ cat platform.txt > ${TEMP_PLATFORM}
5058
sed -ie "s/^version=.*/version=$(extra/get_core_version.sh)/" ${TEMP_PLATFORM}
5159

5260
declutter_file() {
61+
# remove comments and empty lines
5362
[ -f "$1" ] || return 0
5463
cat "$1" | sed -e 's/\s*#.*//' | grep -v '^\s*$'
5564
}
@@ -61,7 +70,7 @@ echo ${TEMP_PLATFORM} >> ${TEMP_INC}
6170
declutter_file extra/artifacts/_common.inc >> ${TEMP_INC}
6271
declutter_file extra/artifacts/$ARTIFACT.inc >> ${TEMP_INC}
6372
for variant in $INCLUDED_VARIANTS ; do
64-
echo "::info::\`${variant}\`"
73+
echo "- ${variant}"
6574
echo "variants/${variant}/" >> ${TEMP_INC}
6675
ls firmwares/zephyr-${variant}.* >> ${TEMP_INC}
6776
done
@@ -78,4 +87,4 @@ tar -cjhf ${OUTPUT_FILE} -X ${TEMP_EXC} -T ${TEMP_INC} \
7887
--transform "s,^,ArduinoCore-zephyr/,"
7988
rm -f ${TEMP_INC} ${TEMP_EXC} ${TEMP_BOARDS} ${TEMP_PLATFORM}
8089

81-
[ -n $GITHUB_WORKSPACE ] && echo "::endgroup::"
90+
log_msg endgroup

0 commit comments

Comments
 (0)