Source Code Update #643
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 Arm64v8 OpenWrt | |
| on: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| env: | |
| REPO_URL: https://github.com/coolsnowwolf/lede | |
| REPO_BRANCH: master | |
| FEEDS_CONF: feeds.conf.default | |
| CONFIG_FILE: arm64v8.config | |
| DIY_P1_SH: diy-part1.sh | |
| DIY_P2_SH: diy-part2.sh | |
| UPLOAD_BIN_DIR: false | |
| UPLOAD_FIRMWARE: true | |
| UPLOAD_COWTRANSFER: false | |
| UPLOAD_WETRANSFER: false | |
| UPLOAD_RELEASE: false | |
| TZ: Asia/Shanghai | |
| PACK_DOWNLOAD_TARGET_PATH: openwrtPack/armvirt64 | |
| KERNEL_REPO_URL: ophub/kernel | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| PRE_PACKAGE_ARTIFACT_ID: ${{ steps.rootfsUpload.outputs.artifact-id }} | |
| steps: | |
| - name: Before freeing up disk space | |
| run: | | |
| echo "Before freeing up disk space" | |
| echo "==============================================================================" | |
| df -hT | |
| echo "==============================================================================" | |
| - name: Free Disk Space | |
| uses: endersonmenezes/free-disk-space@v3 | |
| with: | |
| remove_android: true | |
| remove_dotnet: true | |
| remove_haskell: true | |
| remove_tool_cache: true | |
| remove_swap: true | |
| remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable chromedriver google-cloud-sdk firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-* gfortran* imagemagick* *-jdk mongodb-* mono-* monodoc-* unixodbc-dev ant* perl libgl1-mesa-dri apache2* imagemagick* nginx phantomjs php* libpq-dev r-base* ruby* sphinxsearch" | |
| remove_packages_one_command: true | |
| remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia* /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle* /usr/local/bin/azcopy /usr/share/kotlinc /usr/share/apache-maven-* /usr/local/share/gecko_driver /usr/share/lintian" | |
| - name: Free up disk space complete | |
| run: | | |
| echo "Free up disk space complete" | |
| echo "==============================================================================" | |
| df -hT | |
| echo "==============================================================================" | |
| - name: Create simulated physical disk | |
| run: | | |
| echo "Cleaning up Docker Images" | |
| sudo docker system prune --all --force --volumes | |
| echo "Clean Docker Images complete" | |
| echo "==============================================================================" | |
| df -hT | |
| echo "==============================================================================" | |
| mnt_size=$(expr $(df -h /mnt | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 1) | |
| root_size=$(expr $(df -h / | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 4) | |
| sudo truncate -s "${mnt_size}"G /mnt/mnt.img | |
| sudo truncate -s "${root_size}"G /root.img | |
| LOOP_MNT=$(sudo losetup -f --show /mnt/mnt.img) | |
| LOOP_ROOT=$(sudo losetup -f --show /root.img) | |
| sudo pvcreate "$LOOP_MNT" "$LOOP_ROOT" | |
| sudo vgcreate github "$LOOP_MNT" "$LOOP_ROOT" | |
| sudo lvcreate -n runner -l 100%FREE github | |
| sudo mkfs.xfs -f -i sparse=0 -b size=4096 /dev/github/runner | |
| sudo mkdir -p /builder | |
| sudo mount /dev/github/runner /builder | |
| sudo rm -rf "${GITHUB_WORKSPACE:?}" | |
| sudo mkdir -p "$GITHUB_WORKSPACE" | |
| sudo mount --bind /builder "$GITHUB_WORKSPACE" | |
| sudo chown -R runner:runner "$GITHUB_WORKSPACE" | |
| echo "Disk adjustment finished. Ready for heavy building!" | |
| echo "Simulated physical disk complete" | |
| echo "==============================================================================" | |
| df -hT | |
| echo "==============================================================================" | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Initialization environment | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| sudo -E apt-get -qq update | |
| sudo -E apt-get -qq full-upgrade | |
| sudo -E apt-get -qq install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \ | |
| bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext \ | |
| genisoimage 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 llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf \ | |
| python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion \ | |
| swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev | |
| sudo -E apt-get -qq autoremove --purge | |
| sudo -E apt-get -qq clean | |
| sudo rm -rf /etc/apt/sources.list.d/* /usr/local/lib/android /opt/ghc /usr/share/dotnet /usr/local/graalvm /usr/local/.ghcup \ | |
| /usr/local/share/powershell /usr/local/share/chromium /usr/local/lib/node_modules | |
| sudo timedatectl set-timezone "$TZ" | |
| sudo chown $USER:$GROUPS $GITHUB_WORKSPACE | |
| - name: Clone source code | |
| run: | | |
| git clone --depth=1 $REPO_URL -b $REPO_BRANCH openwrt | |
| - name: Load custom feeds | |
| run: | | |
| [ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default | |
| chmod +x $DIY_P1_SH | |
| cd openwrt | |
| $GITHUB_WORKSPACE/$DIY_P1_SH | |
| - name: Update feeds | |
| run: cd openwrt && ./scripts/feeds update -a | |
| - name: Install feeds | |
| run: cd openwrt && ./scripts/feeds install -a | |
| - name: Load custom configuration | |
| run: | | |
| [ -e files ] && mv files openwrt/files | |
| [ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
| chmod +x $DIY_P2_SH | |
| cd openwrt | |
| $GITHUB_WORKSPACE/$DIY_P2_SH | |
| - name: Download package | |
| id: package | |
| run: | | |
| cd openwrt | |
| make defconfig | |
| make download -j$(($(nproc) * 3 / 2)) | |
| find dl -size -1024c -exec ls -l {} \; | |
| find dl -size -1024c -exec rm -f {} \; | |
| - name: Compile the firmware | |
| id: compile | |
| run: | | |
| cd openwrt | |
| echo -e "CPU $(nproc) thread" | |
| echo -e "$(($(nproc) * 3 / 2)) thread compile" | |
| make -j$(($(nproc) * 3 / 2)) || make -j1 || 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")" >> $GITHUB_ENV | |
| - name: Check space usage | |
| if: (!cancelled()) | |
| run: df -hT | |
| - name: Upload bin directory | |
| uses: actions/upload-artifact@v6 | |
| if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
| with: | |
| name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
| path: openwrt/bin | |
| - name: Organize files | |
| id: organize | |
| if: env.UPLOAD_FIRMWARE == 'true' && steps.compile.outputs.status == 'success' && !cancelled() | |
| run: | | |
| cd openwrt/bin/targets/*/* | |
| rm -rf packages | |
| echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Find Rootfs File | |
| id: findRootfs | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| run: | | |
| set -euo pipefail | |
| ROOT_DIR="${{ env.FIRMWARE }}" | |
| echo "π Searching for *rootfs.tar.gz in: $ROOT_DIR" | |
| ROOTFS_FILE=$(find "$ROOT_DIR" -type f -name '*rootfs.tar.gz' -print -quit || true) | |
| if [[ -z "${ROOTFS_FILE:-}" ]]; then | |
| echo "β rootfs not found in $ROOT_DIR" | |
| echo "π Listing files in $ROOT_DIR" | |
| ls -al "$ROOT_DIR" || true | |
| echo "status=not_found" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "β Found: $ROOTFS_FILE" | |
| BASENAME=$(basename -- "$ROOTFS_FILE") | |
| echo "ROOTFS_FILE=$ROOTFS_FILE" >> $GITHUB_OUTPUT | |
| echo "BASENAME=$BASENAME" >> $GITHUB_OUTPUT | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Upload firmware directory | |
| uses: actions/upload-artifact@v6 | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| with: | |
| name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
| path: | | |
| ${{ env.FIRMWARE }} | |
| !${{ steps.findRootfs.outputs.ROOTFS_FILE }} | |
| - name: Upload Rootfs File | |
| id: rootfsUpload | |
| uses: actions/upload-artifact@v6 | |
| if: steps.findRootfs.outputs.status == 'success' && !cancelled() | |
| with: | |
| name: ${{ steps.findRootfs.outputs.BASENAME }} | |
| path: ${{ steps.findRootfs.outputs.ROOTFS_FILE }} | |
| pack: | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| PACK_PACKAGE_SOC: ['s905x3', 's922x'] | |
| PACK_KERNEL_VERSION_NAME: ['6.6.y', '6.12.y'] | |
| steps: | |
| - name: Free Disk Space | |
| uses: endersonmenezes/free-disk-space@v3 | |
| with: | |
| remove_android: true | |
| remove_dotnet: true | |
| remove_haskell: true | |
| remove_tool_cache: true | |
| remove_swap: true | |
| remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable chromedriver google-cloud-sdk firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-* gfortran* imagemagick* *-jdk mongodb-* mono-* monodoc-* unixodbc-dev ant* perl libgl1-mesa-dri apache2* imagemagick* nginx phantomjs php* libpq-dev r-base* ruby* sphinxsearch" | |
| remove_packages_one_command: true | |
| remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia* /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle* /usr/local/bin/azcopy /usr/share/kotlinc /usr/share/apache-maven-* /usr/local/share/gecko_driver /usr/share/lintian" | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Initialization environment | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| if: needs.build.result == 'success' && !cancelled() | |
| run: | | |
| sudo -E apt-get -qq update | |
| sudo -E apt-get -qq full-upgrade | |
| sudo -E apt-get -qq install util-linux uuid-runtime parted dosfstools e2fsprogs btrfs-progs git | |
| sudo -E apt-get -qq autoremove --purge | |
| sudo -E apt-get -qq clean | |
| sudo rm -rf /etc/apt/sources.list.d/* /usr/local/lib/android /opt/ghc /usr/share/dotnet /usr/local/graalvm /usr/local/.ghcup \ | |
| /usr/local/share/powershell /usr/local/share/chromium /usr/local/lib/node_modules | |
| sudo timedatectl set-timezone "$TZ" | |
| - name: Download Rootfs File | |
| uses: actions/download-artifact@v7 | |
| id: downloadArtifact | |
| if: needs.build.result == 'success' && !cancelled() | |
| with: | |
| artifact-ids: ${{ needs.build.outputs.PRE_PACKAGE_ARTIFACT_ID }} | |
| path: ${{ env.PACK_DOWNLOAD_TARGET_PATH }} | |
| - name: Find Rootfs File | |
| id: findRootfs | |
| if: steps.downloadArtifact.outcome == 'success' && !cancelled() | |
| run: | | |
| set -euo pipefail | |
| ROOT_DIR="${{ env.PACK_DOWNLOAD_TARGET_PATH }}" | |
| echo "π Searching for *rootfs.tar.gz in: $ROOT_DIR" | |
| ROOTFS_FILE=$(find "$ROOT_DIR" -type f -name '*rootfs.tar.gz' -print -quit || true) | |
| if [[ -z "${ROOTFS_FILE:-}" || ! -f "$ROOTFS_FILE" ]]; then | |
| echo "β rootfs not found in $ROOT_DIR" | |
| echo "π Listing files in $ROOT_DIR" | |
| ls -al "$ROOT_DIR" | |
| echo "status=not_found" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| echo "β Found: $ROOTFS_FILE" | |
| echo "rootfsFile=$ROOTFS_FILE" >> $GITHUB_OUTPUT | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Package OpenWrt Firmware | |
| uses: unifreq/openwrt_packit@master | |
| if: steps.findRootfs.outputs.status == 'success' && !cancelled() | |
| env: | |
| OPENWRT_ARMSR: ${{ steps.findRootfs.outputs.rootfsFile }} | |
| PACKAGE_SOC: ${{ matrix.PACK_PACKAGE_SOC }} | |
| KERNEL_REPO_URL: ${{ env.KERNEL_REPO_URL }} | |
| KERNEL_VERSION_NAME: ${{ matrix.PACK_KERNEL_VERSION_NAME }} | |
| KERNEL_AUTO_LATEST: true | |
| - name: Organize files | |
| id: organize | |
| if: env.PACKAGED_STATUS == 'success' && !cancelled() | |
| run: | | |
| cd ${{ env.PACKAGED_OUTPUTPATH }} | |
| rm -rf *rootfs.tar.gz *rootfs.tar.gz.sha | |
| echo "timestamp=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Upload firmware directory | |
| uses: actions/upload-artifact@v6 | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| with: | |
| name: OpenWrt_firmware_${{ matrix.PACK_PACKAGE_SOC }}_${{ matrix.PACK_KERNEL_VERSION_NAME }}_${{ steps.organize.outputs.timestamp }} | |
| path: ${{ env.PACKAGED_OUTPUTPATH }} | |
| - name: Delete workflow runs | |
| uses: ophub/delete-releases-workflows@main | |
| with: | |
| delete_releases: false | |
| # releases_keep_latest: 5 | |
| delete_workflows: true | |
| workflows_keep_day: 7 | |
| gh_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Remove old Releases | |
| uses: ophub/delete-releases-workflows@main | |
| if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
| with: | |
| delete_releases: true | |
| releases_keep_latest: 5 | |
| delete_tags: true | |
| gh_token: ${{ secrets.GITHUB_TOKEN }} |