视频简介

现在越来越多朋友开始编译自己的固件,这样的好处就是更灵活,更客制化,那么都是需要自己搭建环境来编译,现在有一个很便捷的方案,就是利用GitHub ACTIONS 在线云编译。


刚出完教程,发现https://github.com/features/actions/signup出现404了,大家直接到项目里面点击Action选项卡,就可以跳转到激活页面了


一、注册GitHub账号

官网地址:https://github.com/

二、激活GitHub ACTIONS功能

激活地址:https://github.com/features/actions/signup

三、fork 一建脚本项目

https://github.com/KFERMercer/OpenWrt-CI

四、fork L大的LEDE源码

https://github.com/coolsnowwolf/lede

五、进入L大源码目录.github/workflows/

7、打开openwrt-ci.yml,编辑代码(注意:这步我在视频里面演示的是全部拷贝代码替换,图文是直接修改代码就可以)

将左侧编辑栏的push、branches和- master前面的#删除,push和schedule对齐

然后点击右侧的【Start commit】,再点击【Commit changes】

#
# This is free software, lisence use MIT.
# 
# Copyright (C) 2019 P3TERX <https://p3terx.com>
# Copyright (C) 2019 KFERMercer <KFER.Mercer@gmail.com>
# 
# <https://github.com/KFERMercer/OpenWrt-CI>
#

name: OpenWrt-CI

on:
  push:
    branches: 
      - master
  # schedule:
  #   - cron: 0 20 * * *
  # release:
  #   types: [published]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master
        with:
          ref: master

      - name: Initialization environment
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          docker rmi `docker images -q`
          echo "Deleting files, please wait ..."
          sudo rm -rf \
            /usr/share/dotnet \
            /etc/mysql \
            /etc/php
          sudo -E apt-get -y purge \
            azure-cli \
            ghc* \
            zulu* \
            hhvm \
            llvm* \
            firefox \
            google* \
            dotnet* \
            powershell \
            openjdk* \
            mysql* \
            php*
          sudo -E apt-get update
          sudo -E apt-get -y 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 -y autoremove --purge
          sudo -E apt-get clean

      - name: Update feeds
        run: |
          ./scripts/feeds update -a
          ./scripts/feeds install -a

      - name: Costom configure file
        run: |
          rm -f ./.config*
          touch ./.config

          #
          # ========================固件定制部分========================
          # 

          # 
          # 如果不对本区块做出任何编辑, 则生成默认配置固件. 
          # 

          # 以下为定制化固件选项和说明:
          #

          #
          # 有些插件/选项是默认开启的, 如果想要关闭, 请参照以下示例进行编写:
          # 
          #          =========================================
          #         |  # 取消编译VMware镜像:                   |
          #         |  cat >> .config <<EOF                   |
          #         |  # CONFIG_VMDK_IMAGES is not set        |
          #         |  EOF                                    |
          #          =========================================
          #

          # 
          # 以下是一些提前准备好的一些插件选项.
          # 直接取消注释相应代码块即可应用. 不要取消注释代码块上的汉字说明.
          # 如果不需要代码块里的某一项配置, 只需要删除相应行.
          #
          # 如果需要其他插件, 请按照示例自行添加.
          # 注意, 只需添加依赖链顶端的包. 如果你需要插件 A, 同时 A 依赖 B, 即只需要添加 A.
          # 
          # 无论你想要对固件进行怎样的定制, 都需要且只需要修改 EOF 回环内的内容.
          # 

          # 编译x64固件:
          # cat >> .config <<EOF
          # CONFIG_TARGET_x86=y
          # CONFIG_TARGET_x86_64=y
          # CONFIG_TARGET_x86_64_Generic=y
          # EOF

          # 固件压缩:
          # cat >> .config <<EOF
          # CONFIG_TARGET_IMAGES_GZIP=y
          # EOF

          # 编译UEFI固件:
          # cat >> .config <<EOF
          # CONFIG_EFI_IMAGES=y
          # EOF

          # IPv6支持:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_dnsmasq_full_dhcpv6=y
          # CONFIG_PACKAGE_ipv6helper=y
          # EOF

          # 多文件系统支持:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_kmod-fs-nfs=y
          # CONFIG_PACKAGE_kmod-fs-nfs-common=y
          # CONFIG_PACKAGE_kmod-fs-nfs-v3=y
          # CONFIG_PACKAGE_kmod-fs-nfs-v4=y
          # CONFIG_PACKAGE_kmod-fs-ntfs=y
          # CONFIG_PACKAGE_kmod-fs-squashfs=y
          # EOF

          # USB3.0支持:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_kmod-usb-ohci=y
          # CONFIG_PACKAGE_kmod-usb-ohci-pci=y
          # CONFIG_PACKAGE_kmod-usb2=y
          # CONFIG_PACKAGE_kmod-usb2-pci=y
          # CONFIG_PACKAGE_kmod-usb3=y
          # EOF

          # 常用LuCI插件选择:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_luci-app-adbyby-plus=y
          # CONFIG_PACKAGE_luci-app-aria2=y
          # CONFIG_PACKAGE_luci-app-baidupcs-web=y
          # CONFIG_PACKAGE_luci-app-docker=y
          # CONFIG_PACKAGE_luci-app-frpc=y
          # CONFIG_PACKAGE_luci-app-hd-idle=y
          # CONFIG_PACKAGE_luci-app-kodexplorer=y
          # CONFIG_PACKAGE_luci-app-minidlna=y
          # CONFIG_PACKAGE_luci-app-openvpn=y
          # CONFIG_PACKAGE_luci-app-openvpn-server=y
          # CONFIG_PACKAGE_luci-app-qbittorrent=y
          # CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Kcptun=y
          # CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks=y
          # CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Server=y
          # CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Socks=y
          # CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray=y
          # CONFIG_PACKAGE_luci-app-ttyd=y
          # CONFIG_PACKAGE_luci-app-v2ray-server=y
          # CONFIG_PACKAGE_luci-app-verysync=y
          # CONFIG_PACKAGE_luci-app-webadmin=y
          # CONFIG_PACKAGE_luci-app-wireguard=y
          # CONFIG_PACKAGE_luci-app-wrtbwmon=y
          # EOF

          # LuCI主题:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_luci-theme-argon=y
          # CONFIG_PACKAGE_luci-theme-netgear=y
          # EOF

          # 常用软件包:
          # cat >> .config <<EOF
          # CONFIG_PACKAGE_curl=y
          # CONFIG_PACKAGE_htop=y
          # CONFIG_PACKAGE_nano=y
          # CONFIG_PACKAGE_screen=y
          # CONFIG_PACKAGE_tree=y
          # CONFIG_PACKAGE_vim-fuller=y
          # CONFIG_PACKAGE_wget=y
          # EOF

          # 取消编译VMware镜像以及镜像填充 (不要删除被缩进的注释符号):
          # cat >> .config <<EOF
          # # CONFIG_TARGET_IMAGES_PAD is not set
          # # CONFIG_VMDK_IMAGES is not set
          # EOF

          # 
          # ========================固件定制部分结束========================
          # 

          sed -i 's/^[ \t]*//g' ./.config
          make defconfig

      - name: Make download
        run: |
          make download -j8
          find dl -size -1024c -exec ls -l {} \;
          find dl -size -1024c -exec rm -f {} \;

      - name: Compile firmware
        run: |
          echo -e "$(nproc) thread build."
          make -j$(nproc) V=s

      - name: Assemble artifact
        run: |
          rm -rf ./artifact/
          mkdir -p ./artifact/
          find ./bin/targets/ -name "*combined*img*" | xargs -i mv -f {} ./artifact/
          find ./bin/targets/ -name "*sysupgrade*bin*" | xargs -i mv -f {} ./artifact/

      - name: Upload artifact
        uses: actions/upload-artifact@master
        with:
          name: OpenWrt firmware
          path: ./artifact/

八、找到LEDE项目的ACTIONS,查看编译过程

九、编译完成后下载固件

十、如何每天定时同步Lean的源码。

在openwrt-ci.yml中的sudo -E apt-get clean后面加一组workflow即可

- name: 同步最新的源码
        run: |
          git remote add openwrt https://github.com/coolsnowwolf/lede.git
          git pull openwrt master
          git remote -v