Cloud N1 OpenWrt #268
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: Cloud N1 OpenWrt | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'README.md' | |
- 'script.sh' | |
- 'config.sh' | |
schedule: | |
- cron: 0 8 * * 0 | |
env: | |
REPO_URL: https://github.com/coolsnowwolf/lede | |
REPO_BRANCH: master | |
SCRIPT_SH: script.sh | |
CONFIG_SH: config.sh | |
UPLOAD_FIRMWARE: true | |
TZ: Asia/Shanghai | |
KERNEL_VERSION: 6.1.79 | |
jobs: | |
build_openwrt: | |
name: Build OpenWrt and release | |
runs-on: ubuntu-20.04 | |
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: true | |
# 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: true | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: main | |
- name: Disk space | |
run: | | |
echo "Free space:" | |
df -h | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo -E apt-mark hold grub-efi-amd64-signed | |
sudo -E apt-get -qq update --fix-missing | |
sudo -E apt-get -qq full-upgrade | |
sudo -E apt-get -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 | |
sudo timedatectl set-timezone "$TZ" | |
- name: Clone source code | |
run: | | |
git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt | |
cd openwrt | |
useVersionInfo=$(git show -s --date=short --format="date: %cd<br/>commit: %s<br/>commit hash: %H") | |
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV | |
echo "DATE=$(date "+%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "tag_name=$(date +%Y%m%d)" >> $GITHUB_ENV | |
- name: Update feeds | |
run: | | |
[ -e files ] && mv files openwrt/files | |
chmod +x $SCRIPT_SH | |
./$SCRIPT_SH | |
cd openwrt | |
echo "src-git helloworld https://github.com/fw876/helloworld.git" >> "feeds.conf.default" | |
./scripts/feeds update -a | |
cat feeds/packages/utils/xfsprogs/Makefile | |
sed -i 's/TARGET_CFLAGS += -DHAVE_MAP_SYNC/TARGET_CFLAGS += -DHAVE_MAP_SYNC -D_LARGEFILE64_SOURCE/' feeds/packages/utils/xfsprogs/Makefile | |
./scripts/feeds update -a | |
- name: Install feeds | |
run: | | |
cd openwrt | |
./scripts/feeds install -a | |
- name: Load custom configuration | |
run: | | |
chmod +x $CONFIG_SH | |
./$CONFIG_SH | |
- name: Download package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the firmware | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 V=s | |
echo "=======================" | |
echo "Space usage:" | |
echo "=======================" | |
df -h | |
echo "=======================" | |
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin | |
du -h --max-depth=1 ./build_dir | |
du -h --max-depth=1 ./bin | |
rm -rf ./build_dir | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Package Armvirt as OpenWrt | |
uses: ophub/flippy-openwrt-actions@main | |
env: | |
OPENWRT_ARMVIRT: openwrt/bin/targets/*/*/*.tar.gz | |
PACKAGE_SOC: s905d | |
KERNEL_VERSION_NAME: ${{ env.KERNEL_VERSION }} | |
WHOAMI: huangqian8 | |
- name: Organize files | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages openwrt-armvirt-64-default.manifest openwrt-armvirt-64-Image sha256sums version.buildinfo feeds.buildinfo openwrt-armvirt-64-generic-kernel.bin openwrt-armvirt-64-generic.manifest | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware directory | |
uses: actions/upload-artifact@v3 | |
if: steps.organize.outputs.status == 'success' && !cancelled() | |
with: | |
name: OpenWrt_firmware | |
path: | | |
${{ env.FIRMWARE }} | |
${{ env.PACKAGED_OUTPUTPATH }} | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ env.DATE }} ❤️ | N1-OpenWrt 自动编译打包 | |
allowUpdates: true | |
tag: ${{ env.tag_name }} | |
commit: main | |
token: ${{ secrets.actions_release }} | |
body: | | |
编译使用版本: | |
${{ env.useVersionInfo }} | |
刷机固件简介: | |
打包日期:${{ env.PACKAGED_OUTPUTDATE }} | |
内核版本:${{ env.KERNEL_VERSION }} | |
默认IP:192.168.1.1 默认用户名密码: root/password | |
artifacts: "${{ env.FIRMWARE }}/*.*,${{ env.PACKAGED_OUTPUTPATH }}/*.*" | |
- name: Remove old Releases | |
uses: dev-drprasad/[email protected] | |
with: | |
keep_latest: 3 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.actions_release }} |