Build OpenWrt QCA #1205
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: Build OpenWrt QCA | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 0 17 * * 0 | |
| env: | |
| REPO_URL: https://github.com/coolsnowwolf/lede | |
| REPO_BRANCH: master | |
| REPO_HASH: b23965cfb7fa0f0d743ee2c64afac13091335dc2 | |
| FEEDS_CONF: feeds.conf.default | |
| CONFIG_FILE: r7800.config | |
| DIY_P1_SH: diy-part1.sh | |
| DIY_P2_SH: diy-part2.sh | |
| AUTH: ${{ secrets.AUTH }} | |
| TZ: Asia/Shanghai | |
| jobs: | |
| build_QCA: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@main | |
| - name: Clean-up | |
| uses: rokibhasansagar/slimhub_actions@main | |
| - name: Initialization environment | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| sudo -E apt-get -qq update | |
| sudo -E apt-get -qq install $(cat ${GITHUB_WORKSPACE}/depends-ubuntu-2004) | |
| sudo timedatectl set-timezone "$TZ" | |
| - name: Clone source code | |
| run: | | |
| df -hT $PWD | |
| git clone $REPO_URL -b $REPO_BRANCH ${GITHUB_WORKSPACE}/openwrt | |
| if [ ! -z $REPO_HASH ];then | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| git reset --hard $REPO_HASH | |
| fi | |
| - name: Update feeds | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| ./scripts/feeds update -a | |
| - name: Load custom feeds | |
| run: | | |
| [ -e $FEEDS_CONF ] && mv $FEEDS_CONF ${GITHUB_WORKSPACE}/openwrt/feeds.conf.default | |
| cp -vf ${GITHUB_WORKSPACE}/$DIY_P1_SH ${GITHUB_WORKSPACE}/openwrt/ | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| chmod +x $DIY_P1_SH | |
| ./$DIY_P1_SH | |
| - name: Load custom configuration | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| cp -vf ${GITHUB_WORKSPACE}/$DIY_P2_SH ${GITHUB_WORKSPACE}/openwrt/ | |
| chmod +x $DIY_P2_SH | |
| ./$DIY_P2_SH | |
| - name: Install feeds | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| ./scripts/feeds update -i | |
| ./scripts/feeds install -a | |
| - name: Download package | |
| id: package | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| cp -vf ${GITHUB_WORKSPACE}/$CONFIG_FILE ${GITHUB_WORKSPACE}/openwrt/.config | |
| make defconfig | |
| make download -j8 | |
| - name: Compile the firmware | |
| id: compile | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt | |
| echo -e "$(($(nproc) * 2)) thread compile" | |
| make -j$(($(nproc) * 2)) || make -j1 V=s | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
| [ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
| echo "FILE_DATE=_$(date +"%Y%m%d%H%M%S")" >> $GITHUB_ENV | |
| - name: Check space usage | |
| if: (!cancelled()) | |
| run: df -hT | |
| - name: Zip bin directory | |
| if: steps.compile.outputs.status == 'success' && !cancelled() | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt/bin | |
| zip -r ${GITHUB_WORKSPACE}/openwrt/OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}.zip * | |
| - name: Organize files | |
| id: organize | |
| if: steps.compile.outputs.status == 'success' && !cancelled() | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/openwrt/bin/targets/*/* | |
| rm -rf packages | |
| mv ${GITHUB_WORKSPACE}/openwrt/OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}.zip ./ | |
| echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Upload firmware directory | |
| uses: actions/upload-artifact@main | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| with: | |
| name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
| path: ${{ env.FIRMWARE }} | |
| - name: Generate release tag | |
| id: tag | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| run: | | |
| ls ${{ env.FIRMWARE }} | |
| echo "release_tag=$(date +"%Y.%m.%d-%H%M%S")-QCA" >> $GITHUB_OUTPUT | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Generate release info | |
| id: info | |
| if: steps.tag.outputs.status == 'success' && !cancelled() | |
| run: | | |
| echo "## :mega:Update content" > release.txt | |
| echo "" >> release.txt | |
| echo "### Info" >> release.txt | |
| echo "**:minidisc: Build Time: ${{ steps.tag.outputs.release_tag }}**" >> release.txt | |
| touch release.txt | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Upload firmware to release | |
| uses: softprops/action-gh-release@master | |
| if: steps.info.outputs.status == 'success' && !cancelled() | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ steps.tag.outputs.release_tag }} | |
| body_path: release.txt | |
| files: ${{ env.FIRMWARE }}/* | |
| - name: Remove old Releases | |
| uses: dev-drprasad/delete-older-releases@master | |
| if: steps.info.outputs.status == 'success' && !cancelled() | |
| with: | |
| keep_latest: 48 | |
| delete_tags: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete workflow runs | |
| uses: Mattraks/delete-workflow-runs@main | |
| with: | |
| retain_days: 0 | |
| keep_minimum_runs: 1 |