Skip to content

Build Lean's OpenWrt for K2P #130

Build Lean's OpenWrt for K2P

Build Lean's OpenWrt for K2P #130

#=================================================
# Description: Phicomm K2P Openwrt Autobuild
# Lisence: MIT
# Author: tjuyy
#=================================================
name: Build Lean's OpenWrt for K2P
on:
release:
types: [published]
push:
branches:
- master
paths:
- "K2P.config"
schedule:
- cron: 0 0 * * 1
#watch:
# types: [started]
workflow_dispatch:
inputs:
logs:
description: 'You can input logs here'
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
echo "Date_and_RunNumber=$(date -u +'%Y-%m-%d')-#$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "Deleting files, please wait ..."
sudo rm -rf /usr/share/dotnet /etc/apt/sources.list.d/*
#sudo swapoff /swapfile
#sudo rm -f /swapfile
#docker rmi `docker images -q`
#sudo -E apt-get -q purge azure-cli ghc* zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* mysql* php*
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
# curl -fsSL https://raw.githubusercontent.com/P3TERX/dotfiles/master/.bashrc >> ~/.bashrc
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Clone source code
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
run: git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt
- name: add custom source
run: |
cd openwrt
sed -i "/helloworld/d" "feeds.conf.default"
echo "src-git helloworld https://github.com/fw876/helloworld.git" >> "feeds.conf.default"
- name: Update & install feeds
run: cd openwrt && ./scripts/feeds update -a && ./scripts/feeds install -a
- name: Load custom configuration
env:
CONFIG_FILE: "K2P.config"
DIY_SH: "diy.sh"
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_SH
cd openwrt
echo 'CONFIG_KERNEL_BUILD_USER="tjuyy"' >> ./.config
echo "CONFIG_GRUB_TITLE=\"OpenWrt AutoBuild by tjuyy-$Date_and_RunNumber\"" >> ./.config
echo "OpenWrt AutoBuild by tjuyy - $Date_and_RunNumber" >> package/base-files/files/etc/banner
../$DIY_SH
make defconfig
# - name: SSH connection to Actions
# uses: P3TERX/debugger-action@master
- name: Download package
run: |
cd openwrt && make download -j$(($(nproc)+1))
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Multi-thread compile
run: |
cd openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1))
- name: Single-thread compile
if: failure()
run: |
cd openwrt
make -j1 V=s
- name: Upload bin directory
uses: actions/upload-artifact@main
if: always()
with:
name: OpenWrt_K2P_bin-${{ env.Date_and_RunNumber }}
path: openwrt/bin
- name: Remove packages
if: always()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
echo "Firmware_path=$(pwd)" >> $GITHUB_ENV
- name: Upload firmware to Artifact
uses: actions/upload-artifact@main
if: always()
with:
name: OpenWrt-K2P-Firmware-${{ env.Date_and_RunNumber }}
path: ${{ env.Firmware_path }}
- name: Publish release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: openwrt/bin/targets/ramips/mt7621/*
env:
GITHUB_TOKEN: ${{ secrets.RELEASES_DEPLOY_TOKEN }}