forked from shvchk/padavan-builder-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnilabsent_build.yml
More file actions
166 lines (138 loc) · 5.3 KB
/
Copy pathnilabsent_build.yml
File metadata and controls
166 lines (138 loc) · 5.3 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
name: Build firmware
run-name: "Build firmware #${{ github.run_number }}"
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Set up build tools
run: |
sudo apt update
sudo apt install --no-install-recommends -y \
autoconf automake autopoint cmake \
bison build-essential flex gawk \
gettext git gperf libtool libtool-bin \
pkg-config fakeroot kmod cpio doxygen \
texinfo help2man libncurses5-dev \
zlib1g-dev libsqlite3-dev gcc-multilib \
curl dos2unix unzip wget locales xxd libltdl-dev \
libgmp3-dev libmpfr-dev libarchive-tools libblkid-dev
sudo locale-gen --no-purge en_US.UTF-8 ru_RU.UTF-8
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
- name: Get variables
run: |
sed -i 's|\r$||g' variables
grep -hE '^\s*PADAVAN_[A-Z0-9_]+=' variables >> "$GITHUB_ENV"
- name: Download sources and toolchain
run: |
git config --global --add safe.directory '*'
git clone -b "${{ env.PADAVAN_BRANCH }}" "${{ env.PADAVAN_REPO }}" padavan-ng --depth=1
git -C padavan-ng checkout "${{ env.PADAVAN_COMMIT }}"
ARCH=""
case "${{ env.PADAVAN_TOOLCHAIN_URL }}" in
*.tzst|*.tar.zst) ARCH="--zstd" ;;
*.txz|*.tar.xz) ARCH="--xz" ;;
esac
wget -qO- "${{ env.PADAVAN_TOOLCHAIN_URL }}" | tar -C padavan-ng $ARCH -xf - || :
- name: Run custom pre-build script
run: '[[ -f pre-build.sh ]] && . pre-build.sh || :'
- name: Build toolchain
if: ${{ hashFiles('padavan-ng/toolchain/out/mipsel-linux-uclibc/sysroot/lib/libuClibc-*.so') == '' }}
run: |
cd padavan-ng/toolchain
./clean_sources.sh
./build_toolchain.sh
- name: Build firmware
run: |
set +e
for cfg in $(ls configs.build/*.config); do
cp -f "$cfg" padavan-ng/trunk/.config
echo "::group::Build $(basename "$cfg" .config)"
echo "Waiting for the last 589 lines of logs (~10-20 minutes per config)..."
pushd padavan-ng/trunk
sed -i 's|\r$||g' .config
. <(grep -hE '^\s*CONFIG_(VENDOR|FIRMWARE_PRODUCT_ID)=' .config)
TEMP_LOG=$(mktemp)
./clear_tree.sh >/dev/null 2>&1
./build_firmware.sh > "$TEMP_LOG" 2>&1
echo "Showing last 589 lines:"
tail -n 589 "$TEMP_LOG"
rm -f "$TEMP_LOG"
popd
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)"
[[ -n $FW_FILE_NAME ]] || { echo "Firmware file not found"; continue; }
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 "padavan-ng/trunk/images/$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"
continue
fi
FW_PATH="release/${FW_FILE_NAME%.*}"
[[ -d "$FW_PATH" ]] && FW_PATH="${FW_PATH}_$(basename "$cfg" .config)"
mkdir -p "$FW_PATH"
cp -f "padavan-ng/trunk/images/$FW_FILE_NAME" "$FW_PATH"
cp -f "$cfg" "$FW_PATH"
done
- name: Run custom post-build script
run: '[[ -f post-build.sh ]] && . post-build.sh || :'
- name: Check if release files exist
run: |
if ! ls release/* >/dev/null 2>&1; then
echo "❌ No files found in release directory"
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: all_firmware_releases
retention-days: 7
path: |
release/*
prepare-matrix:
runs-on: ubuntu-latest
needs: build
outputs:
files: ${{ steps.collect.outputs.files }}
steps:
- name: Download releases
uses: actions/download-artifact@v7
with:
name: all_firmware_releases
path: release
- id: collect
run: |
FILES=$(ls -d release/*/ 2>/dev/null | xargs -n1 basename \
| jq -R -cs 'split("\n")[:-1]')
echo "files=$FILES" >> $GITHUB_OUTPUT
upload-artifacts:
runs-on: ubuntu-latest
needs: prepare-matrix
if: needs.prepare-matrix.outputs.files != '[]'
strategy:
matrix:
file: ${{ fromJson(needs.prepare-matrix.outputs.files) }}
steps:
- name: Download releases
uses: actions/download-artifact@v7
with:
name: all_firmware_releases
path: release
- name: Upload artifact ${{ matrix.file }}
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.file }}
path: release/${{ matrix.file }}
retention-days: 7