-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (275 loc) · 10.5 KB
/
rebuild.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Rebuild
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
default: '23.05.3'
type: string
board:
description: 'Device board'
required: true
default: 'x86'
type: string
subtarget:
description: 'Device subtarget'
required: true
default: '64'
type: string
workflow_call:
inputs:
version:
required: true
type: string
board:
required: true
type: string
subtarget:
required: true
type: string
env:
DELETE_USELESS_FILES: true
jobs:
build_world:
name: build_world ${{ inputs.version }}-${{ inputs.board }}-${{ inputs.subtarget }}
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
env:
TPATH: ''
CONFBRANCH: 'conf'
TARGETBRANCH: ${{ inputs.version }}-${{ inputs.board }}-${{ inputs.subtarget }}
VERSION: ${{ inputs.version }}
BOARD: ${{ inputs.board }}
SUBTARGET: ${{ inputs.subtarget }}
USIGN_ID: ${{ vars.USIGN_ID }}
USIGN_KEY: ${{ secrets[format('USIGN_{0}', vars.USIGN_ID )] }}
steps:
- name: Check if deployed
shell: bash
run: |
rcode=$(curl -sL -w '%{http_code}' -o /dev/null https://github.com/$GITHUB_REPOSITORY/tree/$TARGETBRANCH)
echo rcode: $rcode
[ "$rcode" = "404" ] || { echo "DEPLOYED=y" >> $GITHUB_ENV; }
- name: Check can be build
shell: bash
run: |
rcode=$(curl -sL -w '%{http_code}' -o /dev/null https://github.com/$GITHUB_REPOSITORY/raw/$CONFBRANCH/$VERSION/$BOARD/$SUBTARGET/config.buildinfo)
echo rcode: $rcode
[ "$rcode" != "404" ] || { >&2 echo No config.buildinfo can be build.; exit 1; }
- name: Import keys
env:
USIGN_PUBKEY_URL: 'https://github.com/${{ github.repository_owner }}/packages/raw/master/keys/usign/${{ env.USIGN_ID }}.pub'
shell: bash
run: |
# usign
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "USIGN_PUBKEY<<$EOF" >> $GITHUB_ENV
curl -sL "$USIGN_PUBKEY_URL" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Maximize build space
if: env.DELETE_USELESS_FILES == 'true' && !cancelled()
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 10240
swap-size-mb: 8192
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
- name: Initialize Environment
shell: bash
run: |
sudo apt update
sudo apt -y install build-essential ccache clang curl flex bison g++ gawk \
gcc-multilib g++-multilib genisoimage gettext git libdw-dev libelf-dev \
libncurses5-dev libssl-dev locales pv pwgen python3 python3-pip \
python3-setuptools qemu-utils rsync signify-openbsd subversion swig unzip \
zlib1g-dev file wget zstd
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.CONFBRANCH }}
- name: Checkout to TARGETBRANCH ${{ env.TARGETBRANCH }}
id: checkout_to_targetbranch
shell: bash
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
#
if [ "$DEPLOYED" = "y" ]; then
git fetch --depth=1 origin $TARGETBRANCH
git checkout -b $TARGETBRANCH --track origin/$TARGETBRANCH
rm -rf *
git add .
else
git checkout --orphan $TARGETBRANCH
git reset .
git commit -m '' --allow-empty --allow-empty-message
git push --set-upstream origin $TARGETBRANCH
fi
- name: Initialize Openwrt Environment
id: init_openwrt_env
if: ${{ steps.checkout_to_targetbranch.outcome == 'success' }}
shell: bash
run: |
git clone --depth 1 --branch v23.05.3 https://github.com/openwrt/openwrt.git openwrt
# .config
curl -Lo openwrt/.config "https://github.com/$GITHUB_REPOSITORY/raw/$CONFBRANCH/$VERSION/$BOARD/$SUBTARGET/config.buildinfo"
# key-build
echo "$USIGN_KEY" > openwrt/key-build
echo "$USIGN_PUBKEY" > openwrt/key-build.pub
# prebuilt LLVM toolchain
op_target_url_prefix="https://downloads.openwrt.org/releases/$VERSION/targets/$BOARD/$SUBTARGET"
sha256sums="$(curl -L "${op_target_url_prefix}/sha256sums")"
curl -Lo llvm-bpf.tar.xz "${op_target_url_prefix}/$(echo "$sha256sums" | sed -n '/\bllvm\b/{s|^[[:xdigit:]]*\s*\*||;p}')"
tar -xJf llvm-bpf.tar.xz -C openwrt/
- name: Build world
id: build_world
if: ${{ steps.init_openwrt_env.outcome == 'success' }}
shell: bash
run: |
group() {
endgroup
echo "::group:: $1"
GROUP=1
}
endgroup() {
if [ -n "$GROUP" ]; then
echo "::endgroup::"
fi
GROUP=
}
trap 'endgroup' ERR
NPROC=$(nproc)
sudo chown -R $USER:$GROUPS openwrt
pushd openwrt
#
group "scripts/feeds update -a"
scripts/feeds update -a
endgroup
#
group "scripts/feeds install <External KernelPackage>"
extfeeds=$(grep '^src-git ' feeds.conf.default | awk '{print $2}' | grep -v luci | tr '\n' ' ')
installs=''
pushd feeds
for feed in $extfeeds; do
cd $feed
installs=${installs:+$installs }$(grep -Er "\\$+\(eval \\$+\(call KernelPackage," | awk -F ':' '{print $1}' | sort -u | awk -F '/' '{print $(NF-1)}')
cd ..
done
popd
installs='openvswitch xtables-addons'
echo installs: $installs
scripts/feeds install $installs
endgroup
#
group "make defconfig"
make defconfig
endgroup
#
group "make prepare -j$NPROC"
make prepare -j$NPROC
endgroup
#
group "make package/compile V=s -j$NPROC"
make package/compile V=s -j$NPROC
endgroup
#
group "make package/install -j$NPROC"
make package/install -j$NPROC
endgroup
#
group "install fantastic feed"
for p in build_dir staging_dir; do
pushd $p/target-*/root-$BOARD/etc/opkg
echo "$USIGN_PUBKEY" > keys/${USIGN_ID,,}
sed -i "/src\/gz openwrt_core /{ \
s|downloads.openwrt.org/releases/$VERSION|github.com/$GITHUB_REPOSITORY/raw/$TARGETBRANCH| \
}" distfeeds.conf
popd
done
endgroup
#
group "make target/install -j$NPROC"
make target/install -j$NPROC
endgroup
#
group "finishing work"
make package/index
make json_overview_image_info
make checksum
endgroup
#
popd
- name: Push packages
id: push_packages
if: ${{ steps.build_world.outcome == 'success' || steps.checkout_to_targetbranch.outcome == 'success' }}
shell: bash
run: |
mv openwrt/bin/* ./
git add packages/ # Non-essential
git add targets/$BOARD/$SUBTARGET/packages/
git add targets/$BOARD/$SUBTARGET/*.buildinfo
git add targets/$BOARD/$SUBTARGET/*.json
git add targets/$BOARD/$SUBTARGET/*.manifest
git add targets/$BOARD/$SUBTARGET/sha256sums
#git commit -m "Upload packages"
#git push
git add targets/$BOARD/$SUBTARGET/*-imagebuilder-*.*
#git commit -m "Upload imagebuilder"
#git push
pushd targets/$BOARD/$SUBTARGET
sdkname=$(basename *-sdk-*.*)
split -b 80m $sdkname ${sdkname}.
popd
git add targets/$BOARD/$SUBTARGET/${sdkname}.*
#git commit -m "Upload sdk"
#git push
git commit -m "Upload packages imagebuilder sdk"
git push
rm -f targets/$BOARD/$SUBTARGET/${sdkname}.*
- name: Upload artifact (All)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: target-${{ env.VERSION }}-${{ env.BOARD }}-${{ env.SUBTARGET }}-all
path: |
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/
!targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/packages/
- name: Upload artifact (Image files)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: target-${{ env.VERSION }}-${{ env.BOARD }}-${{ env.SUBTARGET }}-image
path: |
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*.bin
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*.img
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*.img.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-kernel.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-uImage.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-rootfs.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-factory.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-recovery.*
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-sysupgrade.*
- name: Upload artifact (Supplementary files)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: target-${{ env.VERSION }}-${{ env.BOARD }}-${{ env.SUBTARGET }}-supplementary
path: |
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/kernel-debug.*
- name: Upload artifact (Image Builder)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: target-${{ env.VERSION }}-${{ env.BOARD }}-${{ env.SUBTARGET }}-IB
path: |
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-imagebuilder-*.*
- name: Upload artifact (SDK)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: target-${{ env.VERSION }}-${{ env.BOARD }}-${{ env.SUBTARGET }}-SDK
path: |
targets/${{ env.BOARD }}/${{ env.SUBTARGET }}/*-sdk-*.*