N1-OpenWrt-23.05 #269
This file contains hidden or 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: N1-OpenWrt-23.05 | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: | |
- N1-OpenWrt-23.05 | |
env: | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
steps: | |
- name: Show system | |
run: | | |
echo -e "💬 Server information \n" | |
echo -e "💻 Server running on Ubuntu: [ Release: $(cat /etc/os-release | grep VERSION_CODENAME | cut -d '=' -f2) / Host: $(arch) ] \n" | |
echo -e "🧮 Server CPU configuration information: \n$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \n" | |
echo -e "💾 Server memory usage: \n$(free -h) \n" | |
echo -e "🗃️ Server space usag: \n$(df -hT ${GITHUB_WORKSPACE}) \n" | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
swap-size-mb: 1024 | |
temp-reserve-mb: 512 | |
root-reserve-mb: 4608 | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Init build dependencies | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo -E apt-get -qq update | |
sudo /bin/bash -c "$(curl -sL https://git.io/vokNn)" | |
sudo -E apt-fast -y -qq install asciidoc bash bcc bin86 binutils bison bzip2 clang-15 llvm-15 file flex g++ g++-multilib gawk gcc gcc-multilib gettext git gzip help2man intltool libboost-dev libelf-dev libncurses-dev libncurses5-dev libssl-dev libthread-queue-any-perl libusb-dev libxml-parser-perl make patch perl-modules python3-dev python3-pip python3-pyelftools python3-setuptools rsync sharutils swig time unzip util-linux wget xsltproc zlib1g-dev zip | |
sudo -E apt-fast -y -qq install dos2unix dwarves quilt npm | |
sudo -E npm install -g pnpm | |
pip3 install --user -U pylibfdt --break-system-packages | |
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 'noreply@github.com' | |
sudo -E git config --global core.abbrev auto | |
df -h | |
- name: Prepare source code | |
run: | | |
sudo chown -R runner:runner /home/runner/work/build_openwrt | |
echo "build_date=$(date +%Y.%m.%d)" >> ${GITHUB_ENV} | |
cp -r ./scripts/openwrt-23.05/. ./ | |
/bin/bash 01_prepare_source_code.sh | |
ln -sf /home/runner/work/build_openwrt/build_openwrt/openwrt /home/runner/work/_actions/ffuqiangg/amlogic-s9xxx-openwrt/main/openwrt | |
- name: Prepare package | |
working-directory: ${{ github.workspace }}/openwrt | |
run: | | |
cp -r ../scripts/openwrt-23.05/. ./ | |
/bin/bash 02_prepare_package.sh | |
- name: Load custom configuration | |
run: | | |
latest_release="$(curl -s https://github.com/openwrt/openwrt/tags | grep -Eo "v[0-9\.]+-*r*c*[0-9]*.tar.gz" | sed -n '/23.05/p' | sed -n 1p | sed 's/.tar.gz//g' | sed 's/v//g')" | |
kernel_version="$(cat openwrt/include/kernel-5.15 | grep -oE "[1-9]\.[1-9][0-9]*\.[1-9][0-9]*")" | |
sed -i "s/DATE/${{ env.build_date }}/;s/WRT_SOUR/OpenWrt/;s/RELEASES/${latest_release}/" ./openwrt/files/etc/banner | |
echo "latest_release=${latest_release}" >> ${GITHUB_ENV} | |
echo "kernel_version=${kernel_version}" >> ${GITHUB_ENV} | |
- name: Make config | |
working-directory: ${{ github.workspace }}/openwrt | |
run: | | |
cp -f ../config/openwrt-23.05/config.seed .config | |
make defconfig | |
- name: Download package | |
working-directory: ${{ github.workspace }}/openwrt | |
run: | | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the firmware | |
working-directory: ${{ github.workspace }}/openwrt | |
run: | | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
- name: Upload firmware directory | |
uses: actions/upload-artifact@main | |
with: | |
name: OpenWrt_rootfs_${{ env.build_date }} | |
path: openwrt/bin | |
- name: Packit firmware | |
uses: ffuqiangg/amlogic-s9xxx-openwrt@main | |
with: | |
openwrt_path: openwrt/bin/targets/*/*/*rootfs.tar.gz | |
openwrt_board: s905d | |
kernel_repo: ffuqiangg/kernel_5.15.y | |
openwrt_kernel: ${{ env.kernel_version }} | |
kernel_usage: stable | |
auto_kernel: false | |
openwrt_size: 820 | |
build_date: ${{ env.build_date }} | |
- name: Organize files | |
run: | | |
echo ' | |
默认 IP:192.168.1.1 / 默认密码:password / 使用说明:[README](https://github.com/ffuqiangg/build_openwrt/blob/main/doc/readme.md)' > release.md | |
rm -rf ./artifact/ | |
mkdir -p ./artifact/ | |
cp ${{ env.PACKAGED_OUTPUTPATH }}/*.img.gz ./artifact/ | |
cd ./artifact/ | |
zip N1-OpenWrt-${{ env.latest_release }}-${{ env.build_date }}.zip *.img.gz | |
echo "prerelease_symbol=true" >> ${GITHUB_ENV} | |
if [[ "${{ github.event_name }}" == 'repository_dispatch' ]]; then | |
echo "prerelease_symbol=false" >> ${GITHUB_ENV} | |
fi | |
- name: Upload firmware to release | |
uses: ncipollo/release-action@main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: ${{ env.build_date }} | |
allowUpdates: true | |
replacesArtifacts: true | |
prerelease: ${{ env.prerelease_symbol }} | |
artifacts: ./artifact/*.zip | |
bodyFile: release.md | |
- name: telegram notification | |
if: github.event_name == 'repository_dispatch' | |
run: | | |
firmware_num="$(curl -fsSL https://github.com/ffuqiangg/build_openwrt/releases/expanded_assets/${{ env.build_date }} | grep -oE "N1-.*.zip" | sort -u | wc -l)" | |
MSG=" | |
*${{ env.build_date }}* 固件编译完成 | |
https://github.com/ffuqiangg/build\_openwrt/releases/tag/${{ env.build_date }} | |
" | |
if [[ "${firmware_num}" == 5 ]]; then | |
curl "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" -d "chat_id=${{ secrets.TELEGRAM_TO }}&text=${MSG}&parse_mode=MarkDown&disable_web_page_preview=true" | |
fi |