|
| 1 | +name: NanoPi R2S WAN\AM OpenWrt |
| 2 | +on: |
| 3 | + repository_dispatch: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: 0 23 * * * |
| 7 | + # watch: |
| 8 | + # types: started |
| 9 | + |
| 10 | +env: |
| 11 | + REPO_URL: https://github.com/coolsnowwolf/lede |
| 12 | + REPO_BRANCH: master |
| 13 | + CONFIG_FILE: configs/lean/lean.config |
| 14 | + DIY_SH: scripts/lean-wan&lan.sh |
| 15 | + IPV6MOD_IN_FIRMWARE: true |
| 16 | + KMODS_IN_FIRMWARE: true |
| 17 | + UPLOAD_WETRANSFER: true |
| 18 | + UPLOAD_COWTRANSFER: true |
| 19 | + UPLOAD_RELEASE: true |
| 20 | + TZ: Asia/Shanghai |
| 21 | + |
| 22 | +jobs: |
| 23 | + Build: |
| 24 | + runs-on: ubuntu-18.04 |
| 25 | + if: github.repository == 'DHDAXCW/NanoPi-R2S-2021' |
| 26 | + outputs: |
| 27 | + OPENWRTROOT: ${{ steps.update.outputs.OPENWRTROOT }} |
| 28 | + PLATFORM: ${{ steps.compile.outputs.PLATFORM }} |
| 29 | + TARGET: ${{ steps.compile.outputs.TARGET }} |
| 30 | + SUBTARGET: ${{ steps.compile.outputs.SUBTARGET }} |
| 31 | + FIRMWARE: ${{ steps.compile.outputs.FIRMWARE }} |
| 32 | + GENERATE_STATUS: ${{ steps.generate.outputs.GENERATE_STATUS }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@main |
| 37 | + |
| 38 | + - name: Initialization Environment |
| 39 | + env: |
| 40 | + DEBIAN_FRONTEND: noninteractive |
| 41 | + run: | |
| 42 | + sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc |
| 43 | + sudo -E apt-get -qq update |
| 44 | + sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-1804) tree |
| 45 | + sudo -E apt-get -qq autoremove --purge |
| 46 | + sudo -E apt-get -qq clean |
| 47 | + sudo timedatectl set-timezone "$TZ" |
| 48 | + - name: Clone Source Code |
| 49 | + run: | |
| 50 | + df -hT $PWD |
| 51 | + git config --global user.email "git@github.com" |
| 52 | + git config --global user.name "GitHub" |
| 53 | + git clone $REPO_URL -b $REPO_BRANCH openwrt |
| 54 | + cd openwrt |
| 55 | + chmod +x ./target/linux/rockchip/armv8/base-files/etc/board.d/01_leds |
| 56 | + chmod +x ./target/linux/rockchip/armv8/base-files/etc/board.d/02_network |
| 57 | + |
| 58 | + - name: Update Feeds |
| 59 | + id: update |
| 60 | + run: | |
| 61 | + cd openwrt |
| 62 | + echo "OPENWRTROOT=$PWD" >> $GITHUB_ENV |
| 63 | + echo "::set-output name=OPENWRTROOT::$(echo $PWD)" |
| 64 | + mkdir customfeeds |
| 65 | + git clone --depth=1 https://github.com/coolsnowwolf/packages customfeeds/packages |
| 66 | + git clone --depth=1 https://github.com/coolsnowwolf/luci customfeeds/luci |
| 67 | + chmod +x ../scripts/*.sh |
| 68 | + ../scripts/hook-feeds.sh |
| 69 | + |
| 70 | + - name: Install Feeds |
| 71 | + run: | |
| 72 | + cd $OPENWRTROOT |
| 73 | + ./scripts/feeds install -a |
| 74 | + - name: Load Custom Configuration |
| 75 | + run: | |
| 76 | + [ -e files ] && mv files $OPENWRTROOT/files |
| 77 | + [ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRTROOT/.config |
| 78 | + chmod +x scripts/*.sh |
| 79 | + # cat configs/docker-support.config >> $OPENWRTROOT/.config |
| 80 | + cd $OPENWRTROOT |
| 81 | + ../$DIY_SH |
| 82 | + ../scripts/preset-clash-core.sh armv8 |
| 83 | + ../scripts/preset-terminal-tools.sh |
| 84 | + - name: Download Package |
| 85 | + id: package |
| 86 | + run: | |
| 87 | + cd $OPENWRTROOT |
| 88 | + if "$KMODS_IN_FIRMWARE" = 'true' |
| 89 | + then |
| 90 | + echo "CONFIG_ALL_NONSHARED=y" >> .config |
| 91 | + fi |
| 92 | + make defconfig |
| 93 | + ../scripts/modify_config.sh |
| 94 | + cat .config |
| 95 | + make download -j8 |
| 96 | + find dl -size -1024c -exec ls -l {} \; |
| 97 | + find dl -size -1024c -exec rm -f {} \; |
| 98 | + |
| 99 | + - name: Compile Packages |
| 100 | + id: compile |
| 101 | + run: | |
| 102 | + cd $OPENWRTROOT |
| 103 | + echo -e "$(nproc) thread compile" |
| 104 | + make tools/compile -j$(nproc) || make tools/compile -j1 V=s |
| 105 | + make toolchain/compile -j$(nproc) || make toolchain/compile -j1 V=s |
| 106 | + make target/compile -j$(nproc) || make target/compile -j1 V=s IGNORE_ERRORS=1 |
| 107 | + make diffconfig |
| 108 | + make package/compile -j$(nproc) IGNORE_ERRORS=1 || make package/compile -j1 V=s IGNORE_ERRORS=1 |
| 109 | + make package/index |
| 110 | + cd $OPENWRTROOT/bin/packages/* |
| 111 | + PLATFORM=$(basename `pwd`) |
| 112 | + echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV |
| 113 | + echo "::set-output name=PLATFORM::$(echo $PLATFORM)" |
| 114 | + cd $OPENWRTROOT/bin/targets/* |
| 115 | + TARGET=$(basename `pwd`) |
| 116 | + echo "TARGET=$TARGET" >> $GITHUB_ENV |
| 117 | + echo "::set-output name=TARGET::$(echo $TARGET)" |
| 118 | + cd * |
| 119 | + SUBTARGET=$(basename `pwd`) |
| 120 | + echo "SUBTARGET=$SUBTARGET" >> $GITHUB_ENV |
| 121 | + echo "::set-output name=SUBTARGET::$(echo $SUBTARGET)" |
| 122 | + echo "FIRMWARE=$PWD" >> $GITHUB_ENV |
| 123 | + echo "::set-output name=FIRMWARE::$(echo $PWD)" |
| 124 | + echo "::set-output name=COMPILE_STATUS::success" |
| 125 | + - name: Generate Firmware |
| 126 | + if: steps.compile.outputs.COMPILE_STATUS == 'success' |
| 127 | + id: generate |
| 128 | + run: | |
| 129 | + cd configs/opkg |
| 130 | + sed -i "s/subtarget/$SUBTARGET/g" distfeeds*.conf |
| 131 | + sed -i "s/target\//$TARGET\//g" distfeeds*.conf |
| 132 | + sed -i "s/platform/$PLATFORM/g" distfeeds*.conf |
| 133 | + cd $OPENWRTROOT |
| 134 | + mkdir -p files/etc/uci-defaults/ |
| 135 | + cp ../scripts/init-settings.sh files/etc/uci-defaults/99-init-settings |
| 136 | + mkdir -p files/etc/opkg |
| 137 | + cp ../configs/opkg/distfeeds-packages-server.conf files/etc/opkg/distfeeds.conf.server |
| 138 | + if "$KMODS_IN_FIRMWARE" = 'true' |
| 139 | + then |
| 140 | + mkdir -p files/www/snapshots |
| 141 | + cp -r bin/targets files/www/snapshots |
| 142 | + cp ../configs/opkg/distfeeds-18.06-local.conf files/etc/opkg/distfeeds.conf |
| 143 | + else |
| 144 | + cp ../configs/opkg/distfeeds-18.06-remote.conf files/etc/opkg/distfeeds.conf |
| 145 | + fi |
| 146 | + cp files/etc/opkg/distfeeds.conf.server files/etc/opkg/distfeeds.conf.mirror |
| 147 | + sed -i "s/http:\/\/192.168.123.100:2345\/snapshots/https:\/\/openwrt.cc\/snapshots\/$(date +"%Y-%m-%d")\/lean/g" files/etc/opkg/distfeeds.conf.mirror |
| 148 | + if "$IPV6MOD_IN_FIRMWARE" = 'true' |
| 149 | + then |
| 150 | + mkdir -p files/www/ipv6-modules |
| 151 | + cp bin/packages/$PLATFORM/luci/luci-proto-ipv6* files/www/ipv6-modules |
| 152 | + cp bin/packages/$PLATFORM/base/{ipv6helper*,odhcpd-ipv6only*,odhcp6c*,6in4*} "files/www/ipv6-modules" |
| 153 | + cp bin/targets/$TARGET/$SUBTARGET/packages/{ip6tables*,kmod-nf-nat6*,kmod-ipt-nat6*,kmod-sit*,kmod-ip6tables-extra*} "files/www/ipv6-modules" |
| 154 | + mkdir -p files/bin |
| 155 | + cp ../scripts/ipv6-helper.sh files/bin/ipv6-helper |
| 156 | + fi |
| 157 | + make package/install -j$(nproc) || make package/install -j1 V=s |
| 158 | + make target/install -j$(nproc) || make target/install -j1 V=s |
| 159 | + make checksum |
| 160 | + echo "::set-output name=GENERATE_STATUS::success" |
| 161 | + - name: Upload Bin Folder |
| 162 | + uses: actions/upload-artifact@main |
| 163 | + if: steps.generate.outputs.GENERATE_STATUS == 'success' |
| 164 | + with: |
| 165 | + name: bin-archive |
| 166 | + path: openwrt/bin |
| 167 | + |
| 168 | + Upload: |
| 169 | + needs: [Build] |
| 170 | + runs-on: ubuntu-18.04 |
| 171 | + if: github.repository == 'DHDAXCW/NanoPi-R2S-2021' |
| 172 | + steps: |
| 173 | + - name: Checkout |
| 174 | + uses: actions/checkout@main |
| 175 | + |
| 176 | + - name: Restore Variables |
| 177 | + run: | |
| 178 | + echo "OPENWRTROOT=$(echo '${{needs.Build.outputs.OPENWRTROOT}}')" >> $GITHUB_ENV |
| 179 | + echo "PLATFORM=$(echo '${{needs.Build.outputs.PLATFORM}}')" >> $GITHUB_ENV |
| 180 | + echo "TARGET=$(echo '${{needs.Build.outputs.TARGET}}')" >> $GITHUB_ENV |
| 181 | + echo "SUBTARGET=$(echo '${{needs.Build.outputs.SUBTARGET}}')" >> $GITHUB_ENV |
| 182 | + echo "FIRMWARE=$(echo '${{needs.Build.outputs.FIRMWARE}}')" >> $GITHUB_ENV |
| 183 | + echo "GENERATE_STATUS=$(echo '${{needs.Build.outputs.GENERATE_STATUS}}')" >> $GITHUB_ENV |
| 184 | + |
| 185 | + - name: Download Bin Folder |
| 186 | + uses: actions/download-artifact@v2 |
| 187 | + if: env.GENERATE_STATUS == 'success' |
| 188 | + with: |
| 189 | + name: bin-archive |
| 190 | + path: openwrt/bin |
| 191 | + |
| 192 | + - name: Deploy Packages-Server |
| 193 | + if: env.GENERATE_STATUS == 'success' |
| 194 | + run: | |
| 195 | + mkdir -p server/web/snapshots/targets/$TARGET/$SUBTARGET |
| 196 | + cp -r $OPENWRTROOT/bin/packages server/web/snapshots |
| 197 | + cp -r $OPENWRTROOT/bin/targets/$TARGET/$SUBTARGET/packages server/web/snapshots/targets/$TARGET/$SUBTARGET |
| 198 | + mv server packages-server |
| 199 | + zip -qrm packages-server.zip packages-server |
| 200 | + mv packages-server.zip $OPENWRTROOT/bin/targets/$TARGET/$SUBTARGET |
| 201 | + - name: Organize Files |
| 202 | + id: organize |
| 203 | + if: env.GENERATE_STATUS == 'success' |
| 204 | + run: | |
| 205 | + cd ${FIRMWARE} |
| 206 | + rm -rf packages |
| 207 | + cd $OPENWRTROOT/bin/targets/$TARGET/ |
| 208 | + curl -fsSL git.io/file-transfer | sh |
| 209 | + df -hT $PWD |
| 210 | + echo "::set-output name=ORGANIZE_STATUS::success" |
| 211 | + - name: Upload Firmware To WeTransfer |
| 212 | + id: wetransfer |
| 213 | + if: steps.organize.outputs.ORGANIZE_STATUS == 'success' && env.UPLOAD_WETRANSFER == 'true' |
| 214 | + run: | |
| 215 | + cd $OPENWRTROOT/bin/targets/$TARGET/ |
| 216 | + ./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log |
| 217 | + echo "::warning file=Firmware-Wetransfer.com::$(cat wetransfer.log | grep https)" |
| 218 | + echo "::set-output name=url::$(cat wetransfer.log | grep https | cut -f3 -d" ")" |
| 219 | + - name: Upload Firmware To CowTransfer |
| 220 | + id: cowtransfer |
| 221 | + if: steps.organize.outputs.ORGANIZE_STATUS == 'success' && env.UPLOAD_COWTRANSFER == 'true' |
| 222 | + run: | |
| 223 | + cd $OPENWRTROOT/bin/targets/$TARGET/ |
| 224 | + ./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log |
| 225 | + echo "::warning file=Firmware-Cowtransfer.com::$(cat cowtransfer.log | grep https)" |
| 226 | + echo "::set-output name=url::$(cat cowtransfer.log | grep https | cut -f3 -d" ")" |
| 227 | + - name: Generate release tag |
| 228 | + id: tag |
| 229 | + if: env.UPLOAD_RELEASE == 'true' && !cancelled() |
| 230 | + run: | |
| 231 | + echo "::set-output name=release_tag::$(date +"%Y.%m.%d")wanlan-Lean" |
| 232 | + echo "::set-output name=release_date::$(date +"%Y.%m.%d")" |
| 233 | + touch release.txt |
| 234 | + [ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt |
| 235 | + [ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt |
| 236 | + echo "::set-output name=status::success" |
| 237 | + - name: Upload firmware to release |
| 238 | + uses: softprops/action-gh-release@v1 |
| 239 | + if: steps.tag.outputs.status == 'success' && !cancelled() |
| 240 | + env: |
| 241 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 242 | + with: |
| 243 | + name: ${{ steps.tag.outputs.release_date }} NanoPi R2S-WAM\AN互换 OpenWrt |
| 244 | + tag_name: ${{ steps.tag.outputs.release_tag }} |
| 245 | + body_path: release.txt |
| 246 | + files: ${{ env.FIRMWARE }}/* |
| 247 | + |
| 248 | + - name: Delete workflow runs |
| 249 | + uses: GitRML/delete-workflow-runs@main |
| 250 | + with: |
| 251 | + retain_days: 1 |
| 252 | + keep_minimum_runs: 1 |
| 253 | + |
| 254 | + - name: Remove old Releases |
| 255 | + uses: dev-drprasad/delete-older-releases@v0.1.0 |
| 256 | + if: env.UPLOAD_RELEASE == 'true' && !cancelled() |
| 257 | + with: |
| 258 | + keep_latest: 20 |
| 259 | + delete_tags: true |
| 260 | + env: |
| 261 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 262 | + |
| 263 | + - name: Delete Artifacts |
| 264 | + uses: geekyeggo/delete-artifact@v1 |
| 265 | + with: |
| 266 | + name: | |
| 267 | + bin-archive |
0 commit comments