Generate friWrt Firmware #393
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#===================================================================================== | |
# 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 | |
Generate: | |
needs: prebuild | |
runs-on: ubuntu-latest | |
name: "${{ matrix.target }}; ${{ inputs.tunnel }}" | |
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 | |
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: Compile Firmware | |
id: compile | |
if: steps.scripts.outputs.status == 'success' && !cancelled() | |
run: | | |
cd $WORKING_DIR | |
mkdir -p compiled_images | |
if [[ "$TUNNEL" == "all" && "$BRANCH" != "21.02.7" ]]; then | |
for t in openclash-passwall neko-passwall neko-openclash openclash-passwall-neko openclash passwall neko no-tunnel; do | |
echo "Compiling with VPN Client: $t" | |
if [ "$CLEAN" == "true" ]; echo "Start 'make clean' before building images."; then make clean; fi | |
time bash make-build.sh $PROFILE $t | |
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 | |
done | |
elif [[ "$TUNNEL" == "all" && "$BRANCH" = "21.02.7" ]]; then | |
for t in openclash no-tunnel; do | |
echo "Compiling with VPN Client: $t" | |
if [ "$CLEAN" == "true" ]; echo "Start 'make clean' before building images."; then make clean; fi | |
time bash make-build.sh $PROFILE $t | |
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 | |
done | |
elif [[ ("$TUNNEL" == "neko" || "$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "$BRANCH" != "21.02.7" || "$TUNNEL" == "openclash" || "$TUNNEL" == "no-tunnel" ]]; then | |
echo "Compiling with VPN Client: $TUNNEL" | |
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 "_$TUNNEL" )_$DATE$([ "$REVISION_TAG" == "true" ] && echo _rev).img.gz; done | |
fi | |
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) |