Build ImmortalWrt Firmware #20
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
name: Build ImmortalWrt Firmware | |
on: | |
schedule: | |
- cron: "0 0 * * 5" | |
workflow_dispatch: | |
env: | |
REPO_URL: https://github.com/hanwckf/immortalwrt-mt798x.git | |
REPO_BRANCH: openwrt-21.02 | |
CONFIG_FILE: .config | |
SELF_BEFORE_SH: before-update-custom.sh | |
SELF_AFTER_SH: after-update-custom.sh | |
TZ: Asia/Shanghai | |
FEEDS_CONF: feeds.conf.default | |
jobs: | |
build: | |
name: build-firmware | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
actions: write | |
steps: | |
- name: Free disk space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: false | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo -E apt-get -qq install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \ | |
bzip2 ccache clang clangd cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext gcc-multilib \ | |
g++-multilib git gperf haveged help2man intltool lib32gcc-s1 libc6-dev-i386 libelf-dev libglib2.0-dev \ | |
libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5 libncursesw5-dev libreadline-dev \ | |
libssl-dev libtool lld lldb lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 \ | |
python3 python3-pip python3-ply python3-docutils qemu-utils re2c rsync scons squashfs-tools subversion swig \ | |
texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /srcdir | |
sudo chown $USER:$GROUPS /srcdir | |
- name: Clone source code | |
working-directory: /srcdir | |
run: | | |
echo "Free space:" | |
df -hT $PWD | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /srcdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: Load custom feeds | |
run: | | |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default | |
chmod +x $SELF_BEFORE_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$SELF_BEFORE_SH | |
- name: Update feeds | |
run: cd openwrt && ./scripts/feeds update -a | |
- name: Install feeds | |
run: cd openwrt && ./scripts/feeds install -a | |
- name: Load custom config | |
run: | | |
[ -e files ] && mv files openwrt/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
chmod +x $SELF_AFTER_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$SELF_AFTER_SH | |
- name: Download package | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 V=11 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the firmware | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
# Need Modify https://docs.github.com/zh/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings | |
# grep '^CONFIG_TARGET_DEVICE.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
# [ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
echo "DEVICE_NAME=_xiaomi-ax3000t" >>$GITHUB_ENV | |
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
- name: Check space usage | |
if: (!cancelled()) | |
run: df -hT | |
- name: Upload bin directory | |
uses: actions/upload-artifact@main | |
if: steps.compile.outputs.status == 'success' && !cancelled() | |
with: | |
name: ImmortalWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
path: openwrt/bin | |
- name: Organize files | |
id: organize | |
if: (!cancelled()) | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware directory | |
uses: actions/upload-artifact@main | |
if: steps.organize.outputs.status == 'success' && !cancelled() | |
with: | |
name: ImmortalWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE }} | |
- name: Generate release tag | |
id: tag | |
if: steps.compile.outputs.status == 'success' && !cancelled() | |
run: | | |
echo "release_tag=ImmortalWrt_$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT | |
touch release.txt | |
echo "ImmortalWrt 🌝 xiaomi ax3000t" >> release.txt | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware to release | |
id: release | |
uses: softprops/action-gh-release@v2 | |
if: steps.tag.outputs.status == 'success' && !cancelled() | |
with: | |
tag_name: ${{ steps.tag.outputs.release_tag }} | |
body_path: release.txt | |
files: ${{ env.FIRMWARE }}/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clean Compile | |
id: clean-compile | |
run: | | |
cd openwrt | |
make clean | |
- name: Cache Compile | |
id: cache-compile | |
uses: actions/cache/save@v4 | |
if: steps.compile.outputs.status == 'success' && !cancelled() | |
with: | |
path: openwrt | |
key: ${{ runner.os }}-openwrt-${{ hashFiles('openwrt/feeds.conf.default') }} | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
retain_days: 7 | |
keep_minimum_runs: 3 | |
- name: Remove old Releases | |
uses: dev-drprasad/delete-older-releases@v0.3.4 | |
if: steps.release.outputs.status == 'success' && !cancelled() | |
with: | |
keep_latest: 3 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |