BananaWRT Builder (Stable) #7
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-stable.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 (Stable) | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 1 * * | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: 24.10.0-rc4 | |
BANANAWRT_RELEASE: stable | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: config/stable/.config | |
DIY_P1_SH: diy-part1.sh | |
DIY_P2_SH: diy-part2.sh | |
UPLOAD_BIN_DIR: false | |
UPLOAD_PACKAGE_DIR: true | |
UPLOAD_FIRMWARE: true | |
UPLOAD_RELEASE: true | |
TZ: Europe/Rome | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Source Code | |
uses: actions/[email protected] | |
- name: Set Up Build Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
/bin/bash .github/scripts/setup-env.sh setup | |
- 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/${{ env.BANANAWRT_RELEASE }}/* ${{ 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: Upload Custom Packages | |
if: env.UPLOAD_PACKAGE_DIR == 'true' | |
uses: actions/[email protected] | |
with: | |
name: BananaWRT_packages${{ env.FILE_DATE }} | |
path: ${{ runner.workspace }}/immortalwrt/bin/packages/*/additional_pack/*.ipk | |
- 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='Stable' | |
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" |