├── .github └── workflows │ └── build-openwrt.yml ├── LICENSE ├── README.md ├── diy-part1.sh └── diy-part2.sh /.github/workflows/build-openwrt.yml: -------------------------------------------------------------------------------- 1 | # 2 | # https://github.com/P3TERX/Actions-OpenWrt 3 | # 4 | # File: .github/workflows/openwrt-bulder.yml 5 | # Description: Build OpenWrt using GitHub Actions 6 | # 7 | # Copyright (c) 2019-2024 P3TERX 8 | # 9 | # This is free software, licensed under the MIT License. 10 | # See /LICENSE for more information. 11 | # 12 | 13 | name: OpenWrt Builder 14 | 15 | on: 16 | repository_dispatch: 17 | workflow_dispatch: 18 | 19 | env: 20 | REPO_URL: https://github.com/coolsnowwolf/lede 21 | REPO_BRANCH: master 22 | FEEDS_CONF: feeds.conf.default 23 | CONFIG_FILE: .config 24 | DIY_P1_SH: diy-part1.sh 25 | DIY_P2_SH: diy-part2.sh 26 | UPLOAD_BIN_DIR: false 27 | UPLOAD_FIRMWARE: true 28 | UPLOAD_RELEASE: true 29 | TZ: Asia/Shanghai 30 | 31 | jobs: 32 | build: 33 | runs-on: ubuntu-22.04 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@main 38 | 39 | - name: Initialization environment 40 | env: 41 | DEBIAN_FRONTEND: noninteractive 42 | run: | 43 | sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL 44 | sudo docker image prune --all --force 45 | sudo -E apt-get -qq update 46 | 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 47 | sudo -E apt-get -qq autoremove --purge 48 | sudo -E apt-get -qq clean 49 | sudo timedatectl set-timezone "$TZ" 50 | sudo mkdir -p /workdir 51 | sudo chown $USER:$GROUPS /workdir 52 | 53 | - name: Clone source code 54 | working-directory: /workdir 55 | run: | 56 | df -hT $PWD 57 | git clone $REPO_URL -b $REPO_BRANCH openwrt 58 | ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt 59 | 60 | - name: Load custom feeds 61 | run: | 62 | [ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default 63 | chmod +x $DIY_P1_SH 64 | cd openwrt 65 | $GITHUB_WORKSPACE/$DIY_P1_SH 66 | 67 | - name: Update feeds 68 | run: cd openwrt && ./scripts/feeds update -a 69 | 70 | - name: Install feeds 71 | run: cd openwrt && ./scripts/feeds install -a 72 | 73 | - name: Load custom configuration 74 | run: | 75 | [ -e files ] && mv files openwrt/files 76 | [ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config 77 | chmod +x $DIY_P2_SH 78 | cd openwrt 79 | $GITHUB_WORKSPACE/$DIY_P2_SH 80 | 81 | - name: Download package 82 | id: package 83 | run: | 84 | cd openwrt 85 | make defconfig 86 | make download -j8 87 | find dl -size -1024c -exec ls -l {} \; 88 | find dl -size -1024c -exec rm -f {} \; 89 | 90 | - name: Compile the firmware 91 | id: compile 92 | run: | 93 | cd openwrt 94 | echo -e "$(nproc) thread compile" 95 | make -j$(nproc) || make -j1 || make -j1 V=s 96 | echo "status=success" >> $GITHUB_OUTPUT 97 | grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME 98 | [ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV 99 | echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV 100 | 101 | - name: Check space usage 102 | if: (!cancelled()) 103 | run: df -hT 104 | 105 | - name: Upload bin directory 106 | uses: actions/upload-artifact@main 107 | if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' 108 | with: 109 | name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} 110 | path: openwrt/bin 111 | 112 | - name: Organize files 113 | id: organize 114 | if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() 115 | run: | 116 | cd openwrt/bin/targets/*/* 117 | rm -rf packages 118 | echo "FIRMWARE=$PWD" >> $GITHUB_ENV 119 | echo "status=success" >> $GITHUB_OUTPUT 120 | 121 | - name: Upload firmware directory 122 | uses: actions/upload-artifact@main 123 | if: steps.organize.outputs.status == 'success' && !cancelled() 124 | with: 125 | name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} 126 | path: ${{ env.FIRMWARE }} 127 | 128 | - name: Generate release tag 129 | id: tag 130 | if: env.UPLOAD_RELEASE == 'true' && !cancelled() 131 | run: | 132 | echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT 133 | touch release.txt 134 | [ ${UPLOAD_GOFILE} = true && ${{ steps.gofile.outputs.url }} ] && echo "🔗 [GoFile](${{ steps.gofile.outputs.url }})" >> release.txt 135 | echo "status=success" >> $GITHUB_OUTPUT 136 | 137 | - name: Upload firmware to release 138 | uses: softprops/action-gh-release@master 139 | if: steps.tag.outputs.status == 'success' && !cancelled() 140 | env: 141 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 142 | with: 143 | tag_name: ${{ steps.tag.outputs.release_tag }} 144 | body_path: release.txt 145 | files: ${{ env.FIRMWARE }}/* 146 | 147 | - name: Delete workflow runs 148 | uses: Mattraks/delete-workflow-runs@main 149 | with: 150 | retain_days: 0 151 | keep_minimum_runs: 2 152 | 153 | - name: Remove old Releases 154 | uses: dev-drprasad/delete-older-releases@master 155 | if: env.UPLOAD_RELEASE == 'true' && !cancelled() 156 | with: 157 | keep_latest: 3 158 | delete_tags: true 159 | env: 160 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 161 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 P3TERX 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # actions-openwrt-helloworld 2 | 3 | [![LICENSE](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square&label=LICENSE)](https://github.com/Lancenas/actions-openwrt-helloworld/blob/master/LICENSE) 4 | ![GitHub Stars](https://img.shields.io/github/stars/Lancenas/actions-openwrt-helloworld.svg?style=flat-square&label=Stars&logo=github) 5 | ![GitHub Forks](https://img.shields.io/github/forks/Lancenas/actions-openwrt-helloworld.svg?style=flat-square&label=Forks&logo=github) 6 | 7 | - **感谢** [P3TERX/Actions-OpenWrt](https://github.com/P3TERX/Actions-OpenWrt)和[coolsnowwolf/lede](https://github.com/coolsnowwolf/lede) 8 | - 通过创建流程文件,在线编译helloworld服务固件; 9 | - 第一代passwall源码完全停止开发(开源源码已经移除),基于vuejs脚本语言、焕新UI设计的第二代passwall由Lienol等大神们在私有库闭源开发中,看情况和心情,只有极小可能性以后某天开源,不要过分期待。 10 | - 修改流程文件`REPO_URL:` 不同库地址(默认lean的`https://github.com/coolsnowwolf/lede.git`或Lienol的`https://github.com/Lienol/openwrt`);`REPO_BRANCH:` 不同分支 (以Lienol OpenWrt源码为例分支`dev-master` 激进;`dev-19.07` OpenWrt官方平稳版;`dev-lean-lede` lean的源码)。 11 | - 通过修改`diy-part1.sh`文件修改`feeds.conf.default`配置。默认添加`fw876/helloworld`。 12 | 有能力可以添加包含`passwall`的`lienol-openwrt-package`试试。 13 | - 通过修改`diy-part2.sh`文件可以自定义默认IP,登陆密码等。按我的需要现在的默认IP为192.168.1.11 14 | - 在 Actions 页面选择Build OpenWrt,然后点击Run Workflow按钮,即可开始编译。(如果需要 SSH 连接则把SSH connection to Actions的值改为true) 15 | - 在触发工作流程后,默认`SSH_ACTIONS: true`在 Actions 页面等待执行到`SSH connection to Actions`步骤,会出现下面信息: 16 | *** 17 | `To connect to this session copy-n-paste the following into a terminal or browser:` 18 | 19 | `ssh Y26QeagDtsPXp2mT6me5cnMRd@nyc1.tmate.io` 20 | 21 | `https://tmate.io/t/Y26QeagDtsPXp2mT6me5cnMRd` 22 | *** 23 | - 复制 SSH 连接命令粘贴到终端内执行,或者复制链接在浏览器中打开使用网页终端,登陆云menuconfig。 24 | - 命令:`cd openwrt && make menuconfig` 25 | - 新手参考[OpenWrt MenuConfig设置和LuCI插件选项说明](https://mtom.top/archives/827/) 26 | - 完成后按快捷键`Ctrl+D`或执行`exit`命令退出,后续编译工作将自动进行。 27 | - 这样比较灵活,可以根据路由器硬件通过云`menuconfig`自定义配置固件,不需要再导出`.config`和上传 28 | - 进阶玩法请看P3TERX的博客[中文教程](https://p3terx.com/archives/build-openwrt-with-github-actions.html) 29 | ### 使用同步`.config`多流程编译移步[Actions-Lean-OpenWrt](https://github.com/Lancenas/Actions-Lean-OpenWrt) 30 | -------------------------------------------------------------------------------- /diy-part1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #============================================================= 3 | # https://github.com/P3TERX/Actions-OpenWrt 4 | # File name: diy-part1.sh 5 | # Description: OpenWrt DIY script part 1 (Before Update feeds) 6 | # Lisence: MIT 7 | # Author: P3TERX 8 | # Blog: https://p3terx.com 9 | #============================================================= 10 | 11 | # Uncomment a feed source 12 | sed -i 's/^#\(.*helloworld\)/\1/' feeds.conf.default 13 | 14 | # Add a feed source 15 | # echo 'src-git helloworld https://github.com/fw876/helloworld' >>feeds.conf.default 16 | echo 'src-git passwall https://github.com/xiaorouji/openwrt-passwall' >>feeds.conf.default 17 | -------------------------------------------------------------------------------- /diy-part2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #============================================================ 3 | # https://github.com/P3TERX/Actions-OpenWrt 4 | # File name: diy-part2.sh 5 | # Description: OpenWrt DIY script part 2 (After Update feeds) 6 | # Lisence: MIT 7 | # Author: P3TERX 8 | # Blog: https://p3terx.com 9 | #============================================================ 10 | 11 | # Modify default IP 12 | sed -i 's/192.168.1.1/192.168.1.11/g' package/base-files/files/bin/config_generate 13 | --------------------------------------------------------------------------------