Immortalwrt super-work #4
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: Immortalwrt super-work | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 3 6 * *' | |
watch: | |
types: [started] | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Show system | |
run: | | |
echo -e "Total CPU cores\t: $(nproc)" | |
cat /proc/cpuinfo | grep 'model name' | |
cpu_name=$(cat /proc/cpuinfo | grep "model name" | head -n 1 | awk -F: '{print $2}' | sed 's/^[ \t]*//') | |
if [[ "$cpu_name" =~ "8370C" || "$cpu_name" =~ "7763" ]]; then | |
echo "CPU为8370C或7763,继续执行命令" | |
ulimit -a | |
else | |
echo "CPU不为8370C或7763,性能不足,停止执行命令" | |
exit 1 | |
fi # 这里添加了fi | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
swap-size-mb: 512 | |
temp-reserve-mb: 128 | |
root-reserve-mb: 3072 | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
- name: Init build dependencies | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo swapoff -a | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq install aria2 | |
sudo -E wget -P /usr/local/sbin/ https://github.com/HiGarfield/lede-17.01.4-Mod/raw/master/.github/backup/apt-fast | |
sudo -E chmod -R 755 /usr/local/sbin/apt-fast | |
sudo -E apt-fast -y -qq install 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 libz-dev lib32gcc-s1 git-core python3-pip \ | |
python3-ply coreutils nano | |
sudo -E pip3 install pyelftools | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo -E git config --global user.name 'GitHub Actions' && git config --global user.email '[email protected]' | |
df -h | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Prepare Sources | |
id: prepare | |
run: | | |
sudo chown -R runner:runner /home/runner/work/R2S-R4S-OpenWrt | |
latest_release="$(curl -s https://github.com/immortalwrt/immortalwrt/tags | grep -Eo "v[0-9\.]+\-*r*c*[0-9]*.tar.gz" | sed -n '/[2-9][0-9]/p' | sed -n 1p | sed 's/.tar.gz//g')" | |
git clone -b ${latest_release} --depth 1 https://github.com/immortalwrt/immortalwrt.git openwrt | |
echo "latest_release=${latest_release}" >>$GITHUB_ENV | |
- name: Prepare Package | |
run: | | |
cd openwrt | |
cp -f ../SCRIPTS/prepare_package.sh ./prepare_package.sh | |
/bin/bash prepare_package.sh | |
- name: Copy FILES | |
run: | | |
cd openwrt | |
cp -rf ../PATCHES/files ./files | |
##### 增加这一项预安装openclash的核心软件 ##### | |
- name: Execute preset-clash-core.sh | |
run: | | |
cd openwrt | |
/bin/bash ../SCRIPTS/preset-clash-core.sh arm64 # 如果需要替换参数,请在此修改 | |
##### 增加这一项预安装openclash的核心软件 ##### | |
- name: Make Config | |
run: | | |
cd openwrt | |
mv ../SEED/config-super.seed .config | |
sed -i '/CONFIG_TARGET_ROOTFS_SQUASHFS/d' .config | |
make defconfig | |
- name: Make Download | |
run: | | |
df -h | |
cd openwrt | |
make download -j50 | |
- name: Compile Openwrt | |
id: compileopenwrt | |
continue-on-error: true | |
run: | | |
df -h | |
cd openwrt | |
make -j$(($(nproc) + 1)) || make -j$(($(nproc) + 1)) V=s | |
echo $? | |
- name: If Error | |
if: steps.compileopenwrt.outcome == 'failure' | |
run: | | |
cat openwrt/.config | |
echo '================================================================' | |
cd openwrt && make -j1 V=s | |
- name: Print Disk Space After | |
run: df -h | |
- name: Assemble Artifact | |
id: assemble_artifact | |
run: | | |
rm -rf ./artifact/ | |
mkdir -p ./artifact/ | |
mv openwrt/bin/targets/rockchip/armv8/*sysupgrade.img* ./artifact/ | |
cd ./artifact/ | |
gzip -d *.gz && exit 0 | |
gzip *.img | |
releaseTag=${{ env.latest_release }} | |
sha256sum *.gz | tee R2S-R4S-super-work-$releaseTag-$(date +%Y-%m-%d).sha256sum | |
mv *r2s*ext4* ./R2S-super-work-$releaseTag-$(date +%Y-%m-%d)-ext4.img.gz | |
mv *r4s*ext4* ./R4S-super-work-$releaseTag-$(date +%Y-%m-%d)-ext4.img.gz | |
mv *r2s*squashfs* ./R2S-super-work-$releaseTag-$(date +%Y-%m-%d)-sfs.img.gz | |
mv *r4s*squashfs* ./R4S-super-work-$releaseTag-$(date +%Y-%m-%d)-sfs.img.gz | |
cd ../openwrt | |
cp .config ../artifact/config-full.seed | |
./scripts/diffconfig.sh > ../artifact/config-diff.seed | |
release_tag="R2S-R4S-super-work-${releaseTag}-$(date +%Y-%m-%d | tr -d '[:space:]')" | |
echo "release_tag=${release_tag}" >>$GITHUB_ENV | |
- name: Upload Artifact | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.release_tag }}-artifact | |
path: ./artifact/ | |
- name: Create release | |
id: create_release | |
uses: ncipollo/release-action@main | |
with: | |
name: ${{ env.release_tag }}-ROM | |
allowUpdates: true | |
tag: ${{ env.release_tag }} | |
commit: ${{ github.sha }} # 使用当前工作的 commit | |
replacesArtifacts: true | |
draft: false | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ./artifact/*.gz,./artifact/*.seed,./artifact/*.sha256sum |