-
Notifications
You must be signed in to change notification settings - Fork 11
330 lines (305 loc) · 13.9 KB
/
generate-friwrt.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#=====================================================================================
# Description: Build OpenWrt and ImmortalWrt with Image Builder
# Instructions: https://openwrt.org/docs/guide-user/additional-software/imagebuilder
# Download from: https://downloads.openwrt.org/releases
# https://downloads.immortalwrt.org/releases
#=====================================================================================
name: Generate friWrt Firmware
on:
workflow_dispatch:
inputs:
target:
description: "Select device target:"
required: true
default: "Raspberry Pi 4B"
type: choice
options:
- all
- Raspberry Pi 3B
- Raspberry Pi 4B
- NanoPi-R2S
- NanoPi-R5S
- x86-64
release_branch:
description: "Select the release branch:"
required: true
default: "openwrt:23.05.3"
type: choice
options:
- openwrt:snapshots
- openwrt:21.02.7
- openwrt:23.05.2
- openwrt:23.05.3
- immortalwrt:snapshots
- immortalwrt:21.02.7
- immortalwrt:23.05.1
- immortalwrt:23.05.2
tunnel:
description: "Select VPN Client app (!neko and passwall only support for newer branch with fw4 firewall!):"
required: true
default: "all"
type: choice
options:
- all
- openclash
- neko
- passwall
- neko-openclash
- openclash-passwall
- neko-passwall
- openclash-passwall-neko
- no-tunnel
clean:
description: "Do 'make clean' for each run"
required: false
default: "true"
type: boolean
squashfs:
description: "Generate squashfs image"
required: false
default: "false"
type: boolean
upload-artifacts:
description: "Upload compiled image to Artifacts only"
required: false
default: "false"
type: boolean
upload-prerelease:
description: "Upload as pre-release"
required: false
default: "false"
type: boolean
revision-tag:
description: "Revision img tag"
required: false
default: "false"
type: boolean
env:
RELEASE_BRANCH: ${{ inputs.release_branch }}
ROOTFS_SQUASHFS: ${{ inputs.squashfs }}
TUNNEL: ${{ inputs.tunnel }}
CLEAN: ${{ inputs.clean }}
TZ: Asia/Jakarta
PRE_RELEASE: ${{ inputs.upload-prerelease }}
REVISION_TAG: ${{ inputs.revision-tag }}
jobs:
prebuild:
runs-on: ubuntu-latest
name: ${{ inputs.release_branch }}
outputs:
target: ${{ steps.set-matrix.outputs.target }}
steps:
- name: Set Matrix Run
id: set-matrix
run: |
if [ "${{ inputs.target }}" == "all" ]; then
echo "target=['Raspberry Pi 3B','Raspberry Pi 4B','x86-64']" >> $GITHUB_OUTPUT
else
echo "target=['${{ inputs.target }}']" >> $GITHUB_OUTPUT
fi
- name: Checking Tunnel Option
run: |
if [[ ("$TUNNEL" == "neko" || "$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "${RELEASE_BRANCH#*:}" == "21.02.7" ]]; then
echo "Cannot continue the process because the selected tunnel [ $TUNNEL ]"
echo "only support for newer branch with fw4 firewall!"
exit 1
else
echo "Selected tunnel option: [ $TUNNEL ]"
fi
Devices:
needs: prebuild
runs-on: ubuntu-latest
name: "${{ matrix.target }}"
strategy:
fail-fast: false
matrix:
target: ${{fromJSON(needs.prebuild.outputs.target)}}
steps:
- name: Initialization System Environment
run: |
sudo apt-get -qq update
sudo apt-get -qq install build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc rsync wget unzip tar gzip qemu-utils mkisofs
sudo timedatectl set-timezone "$TZ"
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
- name: Setup Environment Variables
run: |
if [ "$TARGET" == "Raspberry Pi 3B" ]; then
echo "PROFILE=rpi-3" >> $GITHUB_ENV
echo "TARGET_SYSTEM=bcm27xx/bcm2710" >> $GITHUB_ENV
echo "TARGET_NAME=bcm27xx-bcm2710" >> $GITHUB_ENV
TARGET_NAME="bcm27xx-bcm2710"
echo "ARCH_1=armv7" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_cortex-a53" >> $GITHUB_ENV
elif [ "$TARGET" == "Raspberry Pi 4B" ]; then
echo "PROFILE=rpi-4" >> $GITHUB_ENV
echo "TARGET_SYSTEM=bcm27xx/bcm2711" >> $GITHUB_ENV
echo "TARGET_NAME=bcm27xx-bcm2711" >> $GITHUB_ENV
TARGET_NAME="bcm27xx-bcm2711"
echo "ARCH_1=arm64" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_cortex-a72" >> $GITHUB_ENV
elif [ "$TARGET" == "NanoPi-R2S" ]; then
echo "PROFILE=friendlyarm_nanopi-r2s" >> $GITHUB_ENV
echo "TARGET_SYSTEM=rockchip/armv8" >> $GITHUB_ENV
echo "TARGET_NAME=rockchip-armv8" >> $GITHUB_ENV
TARGET_NAME="rockchip-armv8"
echo "ARCH_1=armv8" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_generic" >> $GITHUB_ENV
elif [ "$TARGET" == "NanoPi-R5S" ]; then
echo "PROFILE=friendlyarm_nanopi-r5s" >> $GITHUB_ENV
echo "TARGET_SYSTEM=rockchip/armv8" >> $GITHUB_ENV
echo "TARGET_NAME=rockchip-armv8" >> $GITHUB_ENV
TARGET_NAME="rockchip-armv8"
echo "ARCH_1=armv8" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_generic" >> $GITHUB_ENV
elif [ "$TARGET" == "x86-64" ]; then
echo "PROFILE=generic" >> $GITHUB_ENV
echo "TARGET_SYSTEM=x86/64" >> $GITHUB_ENV
echo "TARGET_NAME=x86-64" >> $GITHUB_ENV
TARGET_NAME="x86-64"
echo "ARCH_1=amd64" >> $GITHUB_ENV
echo "ARCH_2=x86_64" >> $GITHUB_ENV
echo "ARCH_3=x86_64" >> $GITHUB_ENV
fi
echo "WORKING_DIR="${RELEASE_BRANCH%:*}"-imagebuilder-"$TARGET_NAME".Linux-x86_64" >> $GITHUB_ENV
echo "DOWNLOAD_BASE=https://downloads."${RELEASE_BRANCH%:*}".org" >> $GITHUB_ENV
echo "BASE=${RELEASE_BRANCH%:*}" >> $GITHUB_ENV
echo "BRANCH=${RELEASE_BRANCH#*:}" >> $GITHUB_ENV
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "DATETIME=$(date +'%Y.%m.%d-%H:%M:%S')" >> $GITHUB_ENV
echo "DATEMONTH=$(date +"%B-%Y" | awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
path: origin
- name: Download Image Builder
id: download
run: |
SNAPSHOTS="$DOWNLOAD_BASE/$BRANCH/targets/$TARGET_SYSTEM/$BASE-imagebuilder-$TARGET_NAME.Linux-x86_64.tar.xz"
RELEASE="$DOWNLOAD_BASE/releases/$BRANCH/targets/$TARGET_SYSTEM/$BASE-imagebuilder-$BRANCH-$TARGET_NAME.Linux-x86_64.tar.xz"
[ "$BRANCH" == "snapshots" ] && wget -nv "$SNAPSHOTS" || wget -nv "$RELEASE"
tar -xJf *-imagebuilder-* && sync && rm -f *-imagebuilder-*.tar.xz && mv *-imagebuilder-* $WORKING_DIR && sync
cp -r $GITHUB_WORKSPACE/origin/* $GITHUB_WORKSPACE/$WORKING_DIR
echo "status=success" >> $GITHUB_OUTPUT
- name: Download External Packages
id: packages
if: steps.download.outputs.status == 'success' && !cancelled()
run: |
cd $WORKING_DIR
bash scripts/external-package-urls.sh
[ "$ARCH_1" == "amd64" ] && ARCH_1=x86
if [[ "$BRANCH" == "21.02.7" ]]; then
grep -E "^all-all|^old-21.02|^$ARCH_1-21.02|^$ARCH_1" external-package-urls.txt | awk '{print $2}' > output_url.txt
else
grep -E "^all-all|^all|^$ARCH_1" external-package-urls.txt | grep -vE "^$ARCH_1-21.02" | awk '{print $2}' > output_url.txt
fi
wget --no-check-certificate -i output_url.txt -nv -P packages
echo "status=success" >> $GITHUB_OUTPUT
- name: Run Patch and DIY Scripts
id: scripts
if: steps.packages.outputs.status == 'success' && !cancelled()
run: |
cd $WORKING_DIR
bash scripts/builder-patch.sh
bash scripts/agh-core.sh
bash scripts/misc.sh
if [[ "$TUNNEL" == "all" && "$BRANCH" != "21.02.7" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh openclash-passwall-neko
elif [[ ("$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "$BRANCH" != "21.02.7" || "$TUNNEL" == "openclash" || "$TUNNEL" == "neko" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh "$TUNNEL"
elif [[ "$TUNNEL" == "all" && "$BRANCH" = "21.02.7" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh openclash
else
echo "No VPN Client selected"
fi
if [ "$TUNNEL" = "openclash" ] || [ "$TUNNEL" = "openclash-passwall" ]; then bash scripts/clash-core.sh; fi
if [ "$TUNNEL" = "neko" ] || [ "$TUNNEL" = "neko-passwall" ]; then bash scripts/neko_core.sh; fi
if [ "$TUNNEL" = "openclash-passwall-neko" ] || [ "$TUNNEL" == "neko-openclash" ] || [ "$TUNNEL" = "all" ]; then bash scripts/clash-core.sh; bash scripts/neko_core.sh; fi
echo "Total custom packages: $(find packages -type f -name "*.ipk" | wc -l)"
ls packages
echo "status=success" >> $GITHUB_OUTPUT
echo -e "Server space usage before starting to compile: \n$(df -hT ${PWD}) \n"
- name: Set Matrix Run Tunnel
id: set-matrix-tunnel
run: |
if [ "${{ inputs.tunnel }}" == "all" ]; then
echo "tunnel=['openclash','neko','passwall','neko-openclash','openclash-passwall','neko-passwall','openclash-passwall-neko','no-tunnel']" >> $GITHUB_OUTPUT
else
echo "tunnel=['${{ inputs.tunnel }}']" >> $GITHUB_OUTPUT
fi
Compile:
needs: Devices
runs-on: ubuntu-latest
name: "${{ set-matrix-tunnel }}"
strategy:
fail-fast: false
matrix:
tunnel: ${{fromJSON(needs.Devices.outputs.tunnel)}}
steps:
- name: Tunnel Option
run: |
echo "TUNNEL=${{ matrix.tunnel }}" >> $GITHUB_ENV
- name: Compile Firmware
id: compile
run: |
cd $WORKING_DIR
mkdir -p compiled_images
if [ "$CLEAN" == "true" ]; echo "Start 'make clean' before building images."; then make clean; fi
time bash make-build.sh "$PROFILE" "$TUNNEL"
rm -rf bin/targets/"$TARGET_SYSTEM"/*.{json,manifest,bin,*-rootfs*,*factory*,sha256sums}
for file in bin/targets/"$TARGET_SYSTEM"/*-"$TARGET_NAME"-*.img.gz; do mv "$file" compiled_images/fri_$(basename "$file" .img.gz)$( echo "_$t" )_$DATE$([ "$REVISION_TAG" == "true" ] && echo _rev).img.gz; done
if wget -q https://github.com/frizkyiman/friWrt-MyWrtBuilder/releases/download/${{ env.PROFILE }}-${{ env.BASE }}-${{ env.BRANCH }}-${{ env.DATEMONTH }}/sha256sums; then
sha256sum compiled_images/fri_*.img.gz >> compiled_images/sha256sums
else
sha256sum compiled_images/fri_*.img.gz > compiled_images/sha256sums
fi
ls -l compiled_images
echo "RELEASE_TAG=$PROFILE-$BASE-$BRANCH-$DATEMONTH$([ "$REVISION_TAG" == "true" ] && echo -rev)" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
echo -e "Server space usage after compilation: \n$(df -hT ${PWD}) \n"
- name: Upload All Firmware to Artifacts
if: github.event.inputs.upload-artifacts == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_TAG }}
path: ${{ env.WORKING_DIR }}/compiled_images//*
- name: Add changelog info to new release description
if: github.event.inputs.upload-artifacts == 'false'
id: changelog
shell: bash
run: |
cd $WORKING_DIR
r=$(awk '/^\*\*Changelog\*\*/ {if(found) exit; found=1} found' changelog.md)
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "CHANGELOG=$r" >> $GITHUB_OUTPUT
- name: Upload Firmware to Release
uses: svenstaro/upload-release-action@v2
if: github.event.inputs.upload-artifacts == 'false'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ${{ env.WORKING_DIR }}/compiled_images//*
asset_name: ${{ github.event.repository.name }}-${{ github.sha }}
tag: ${{ env.RELEASE_TAG }}
release_name: ${{ env.RELEASE_TAG }}
overwrite: true
prerelease: ${{ env.PRE_RELEASE }}
body: |
![GitHub Downloads (all assets, specific tag)](https://img.shields.io/github/downloads/frizkyiman/friWrt-MyWrtBuilder/${{ env.RELEASE_TAG }}/total?style=for-the-badge&logo=Openwrt)
### friWrt ${{ env.BASE }}-${{ env.BRANCH }} Image information
Build date: ${{ env.DATETIME }}
${{ steps.changelog.outputs.CHANGELOG }}
See [here](https://github.com/frizkyiman/friWrt-MyWrtBuilder?tab=readme-ov-file#firmware-details) for more detail feature and other information.
- Default IP: 192.168.1.1
- Default username: root
- Default password: friwrt
- Default WIFI name: friWrt_2g | friWrt_5g (if device supported)
- Default WIFI password: friwrt2024 (if device supported)