forked from shvchk/padavan-builder-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.96 KB
/
build.yml
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
name: Build firmware
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
container: registry.gitlab.com/hadzhioglu/padavan-ng
defaults: { run: { shell: bash } }
steps:
- uses: actions/checkout@v4
- name: Get variables
run: |
sed -i 's|\r$||g' variables build.config
. <(cat variables build.config)
PADAVAN_THEMES="${PADAVAN_THEMES[*]}"
for v in "${!PADAVAN_@}" "${!CONFIG_@}"; do
echo "$v=${!v}" >> $GITHUB_ENV
done
- name: Download sources and toolchain
run: |
git config --global --add safe.directory '*'
git clone -b "$PADAVAN_BRANCH" "$PADAVAN_REPO"
git -C padavan-ng checkout "$PADAVAN_COMMIT"
wget -qO- "$PADAVAN_TOOLCHAIN_URL" | tar -C padavan-ng --zstd -xf -
- name: Install themes
run: |
if [[ -n $PADAVAN_THEMES ]]; then
git clone --depth 1 -b "$PADAVAN_THEMES_BRANCH" "$PADAVAN_THEMES_REPO" themes
cp -r themes/common-theme themes/jquery.js padavan-ng/trunk/user/www/n56u_ribbon_fixed
for theme in $PADAVAN_THEMES; do
echo "Installing $theme theme"
cp -r "themes/$theme-theme" padavan-ng/trunk/user/www/n56u_ribbon_fixed
done
fi
- name: Run custom pre-build script
run: '[[ -f pre-build.sh ]] && . pre-build.sh || :'
- name: Build firmware
run: |
cp build.config padavan-ng/trunk/.config
pushd padavan-ng/trunk
./clear_tree.sh
./build_firmware.sh
popd
- name: Run custom post-build script
run: '[[ -f post-build.sh ]] && . post-build.sh || :'
- name: Prepare artifacts
run: |
FW_FILE_NAME="$(find padavan-ng/trunk/images -type f -regextype posix-extended -iregex ".*\.(trx|bin)$" \
-printf "%T@\t%f\n" | sort -V | tail -1 | cut -f2)"
cp "padavan-ng/trunk/images/$FW_FILE_NAME" .
echo "FW_FILE_NAME=$FW_FILE_NAME" >> $GITHUB_ENV
echo "BUILD_TIMESTAMP=$(date '+%Y.%m.%d_%H.%M.%S')" >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: padavan-ng_${{ env.CONFIG_VENDOR }}_${{ env.CONFIG_FIRMWARE_PRODUCT_ID }}_${{ env.BUILD_TIMESTAMP }}
retention-days: 7
path: |
${{ env.FW_FILE_NAME }}
build.config
- name: Check firmware size
run: |
partitions=padavan-ng/trunk/configs/boards/$CONFIG_VENDOR/$CONFIG_FIRMWARE_PRODUCT_ID/partitions.config
max_fw_size="$(awk '/Firmware/ { getline; getline; sub(",", ""); print strtonum($2); }' "$partitions")"
fw_size="$(stat -c %s "$FW_FILE_NAME")"
if ((fw_size > max_fw_size)); then
fw_size_fmtd="$(numfmt --grouping "$fw_size") bytes"
max_fw_size_fmtd="$(numfmt --grouping "$max_fw_size") bytes"
echo "Firmware size ($fw_size_fmtd) exceeds max size ($max_fw_size_fmtd) for your target device"
exit 1
fi