BananaWRT Builder (Nightly) #1
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
# | |
# https://github.com/P3TERX/Actions-OpenWrt | |
# | |
# File: .github/workflows/immortalwrt-builder-nightly.yml | |
# Description: Build ImmortalWRT using GitHub Actions | |
# | |
# Copyright (c) 2019-2024 P3TERX <https://p3terx.com> | |
# Copyright (c) 2024-2025 SuperKali <[email protected]> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
name: BananaWRT Builder (Nightly) | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 * * 0 | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: 24.10.0-rc3 | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: config/nightly/.config | |
DIY_P1_SH: diy-part1.sh | |
DIY_P2_SH: diy-part2.sh | |
UPLOAD_BIN_DIR: false | |
UPLOAD_FIRMWARE: true | |
UPLOAD_RELEASE: true | |
TZ: Europe/Rome | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Source Code | |
uses: actions/[email protected] | |
- name: Set Up Build Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL | |
sudo docker image prune --all --force | |
sudo apt-get -qq update | |
sudo apt-get -qq install -y \ | |
ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \ | |
bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext \ | |
gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 \ | |
libelf-dev libfuse-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev \ | |
libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev \ | |
libssl-dev libtool lrzsz mkisofs msmtp ninja-build p7zip p7zip-full patch \ | |
pkgconf python2.7 python3 python3-pyelftools python3-setuptools qemu-utils \ | |
rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \ | |
vim wget xmlto xxd zlib1g-dev | |
sudo apt-get -qq autoremove --purge -y | |
sudo apt-get -qq clean | |
- name: Set timezone on the host | |
run: sudo timedatectl set-timezone "$TZ" || echo "Failed to set timezone, proceeding anyway." | |
- name: Authenticate GitHub | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
echo "machine github.com login ${{ secrets.PERSONAL_ACCESS_TOKEN }}" > ~/.netrc | |
chmod 600 ~/.netrc | |
- name: Clone ImmortalWRT Repository | |
working-directory: ${{ runner.workspace }} | |
run: | | |
git clone $REPO_URL -b v"$REPO_BRANCH" immortalwrt | |
- name: Apply Custom Feeds Configuration | |
run: | | |
[ -e ${{ env.FEEDS_CONF }} ] && mv ${{ env.FEEDS_CONF }} ${{ runner.workspace }}/immortalwrt/feeds.conf.default | |
chmod +x ${{ env.DIY_P1_SH }} | |
cd ${{ runner.workspace }}/immortalwrt | |
$GITHUB_WORKSPACE/${{ env.DIY_P1_SH }} | |
- name: Add Custom DTS Files | |
run: | | |
cp -r dts/* ${{ runner.workspace }}/immortalwrt/target/linux/mediatek/dts/ | |
- name: Update Package Feeds | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt | |
./scripts/feeds update -a | |
- name: Install Package Feeds | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt | |
./scripts/feeds install -a | |
- name: Apply Custom Configuration | |
run: | | |
[ -e files ] && mv files ${{ runner.workspace }}/immortalwrt/files | |
[ -e ${{ env.CONFIG_FILE }} ] && mv ${{ env.CONFIG_FILE }} ${{ runner.workspace }}/immortalwrt/.config | |
chmod +x ${{ env.DIY_P2_SH }} | |
cd ${{ runner.workspace }}/immortalwrt | |
$GITHUB_WORKSPACE/${{ env.DIY_P2_SH }} | |
./scripts/feeds install -p additional_pack -a | |
- name: Diffconfig with current configuration | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt | |
./scripts/diffconfig.sh > diffconfig | |
curl https://downloads.immortalwrt.org/releases/$REPO_BRANCH/targets/mediatek/filogic/config.buildinfo | |
cat diffconfig >> config.buildinfo | |
mv config.buildinfo .config | |
[ -n "$REPO_BRANCH" ] && sed -i \ | |
-e 's|^CONFIG_VERSION_REPO=.*|CONFIG_VERSION_REPO="https://downloads.immortalwrt.org/releases/'"$REPO_BRANCH"'"|g' \ | |
.config | |
- name: Download Required Packages | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt | |
make defconfig | |
make download -j$(nproc) | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Build Firmware | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt | |
make -j$(nproc) || make -j1 V=s | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
echo "FILE_DATE=$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV | |
- name: Check Disk Usage | |
run: df -hT | |
- name: Upload Binary Files | |
if: env.UPLOAD_BIN_DIR == 'true' | |
uses: actions/[email protected] | |
with: | |
name: BananaWRT_bin${{ env.FILE_DATE }} | |
path: ${{ runner.workspace }}/immortalwrt/bin | |
- name: Prepare Firmware for Upload | |
run: | | |
cd ${{ runner.workspace }}/immortalwrt/bin/targets/*/* | |
rm -rf packages | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
- name: Upload Firmware Files | |
if: env.UPLOAD_FIRMWARE == 'true' | |
uses: actions/[email protected] | |
with: | |
name: BananaWRT_firmware${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE }} | |
- name: Create Release Tag | |
if: env.UPLOAD_RELEASE == 'true' | |
run: | | |
release_date=$(date +'%Y.%m.%d-%H%M') | |
kernel_version=$(find ${{ runner.workspace }}/immortalwrt/build_dir/target-*/linux-*/ -type d -regex '.*/linux-[0-9]+\.[0-9]+.*' | head -n 1 | sed -E 's|.*/linux-||') | |
target_devices=$(grep '^CONFIG_TARGET.*DEVICE.*=y' ${{ runner.workspace }}/immortalwrt/.config | sed -r 's/.*DEVICE_(.*)=y/\1/') | |
release_type='Nightly' | |
sed -e "s|{{BANANAWRT_KERNEL}}|${kernel_version}|g" \ | |
-e "s|{{RELEASE_TYPE}}|${release_type}|g" \ | |
-e "s|{{BANANAWRT_VERSION}}|${REPO_BRANCH}|g" \ | |
-e "s|{{RELEASE_DATE}}|$(date '+%Y-%m-%d %H:%M:%S')|g" \ | |
-e "s|{{TARGET_DEVICES}}|${target_devices}|g" \ | |
templates/release-notes-template.md > release.txt | |
echo "release_tag=${release_date}" >> $GITHUB_ENV | |
- name: Publish Firmware Release | |
if: env.UPLOAD_RELEASE == 'true' | |
uses: softprops/[email protected] | |
with: | |
tag_name: ${{ env.release_tag }} | |
body_path: release.txt | |
files: ${{ env.FIRMWARE }}/* | |
- name: Remove old Releases | |
uses: dev-drprasad/[email protected] | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
keep_latest: 7 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Delete workflow runs | |
uses: Mattraks/[email protected] | |
with: | |
retain_days: 0 | |
keep_minimum_runs: 7 | |
- name: Cleanup Workspace | |
if: always() | |
run: | | |
sudo rm -rf ~/.netrc | |
sudo rm -rf "${{ runner.workspace }}/immortalwrt" |