Build OpenWrt for GL-MT6000 #168
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 for GL-MT6000 | |
| permissions: | |
| contents: write | |
| actions: write | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "38 1 */3 * *" | |
| env: | |
| REMOTE_REPOSITORY: pesa1234/openwrt | |
| CONFIG_FILE: mt6000.config | |
| GH_TOKEN: ${{ github.token }} | |
| jobs: | |
| check_commits: | |
| name: Check for new commits | |
| runs-on: ubuntu-24.04-arm | |
| outputs: | |
| remote_branch: ${{ steps.check_commits.outputs.remote_branch }} | |
| release_prefix: ${{ steps.check_commits.outputs.release_prefix }} | |
| new_commits: ${{ steps.check_commits.outputs.new_commits }} | |
| latest_commit_sha: ${{ steps.check_commits.outputs.latest_commit_sha }} | |
| steps: | |
| - name: Check for new commits in pesa1234 repo | |
| id: check_commits | |
| run: | | |
| remote_branch=$(git ls-remote https://github.com/${{ env.REMOTE_REPOSITORY }}.git "refs/heads/next-*" | sed -e 's|\(.*heads/\)||' | grep -viE 'test|beta' | sort -V | tail -n1) | |
| [ -n "$remote_branch" ] && latest_commit_sha=$(gh api "repos/${{ env.REMOTE_REPOSITORY }}/commits/${remote_branch}" --jq .sha) | |
| [ -z "$latest_commit_sha" ] && { echo "*** COULD NOT GET latest_commit_sha FROM remote_branch=$remote_branch ***" ; exit 1; } | |
| gh api "repos/${{ github.repository }}/releases/latest" --jq .body 2>/dev/null | grep -q "${latest_commit_sha}" && echo "new_commits=false" >> $GITHUB_OUTPUT || echo "new_commits=true" >> $GITHUB_OUTPUT | |
| echo "remote_branch=${remote_branch}" | |
| echo "release_prefix=${remote_branch%.rss*}" | |
| echo "latest_commit_sha=$latest_commit_sha" | |
| echo "remote_branch=${remote_branch}" >> $GITHUB_OUTPUT | |
| echo "release_prefix=${remote_branch%.rss*}" >> $GITHUB_OUTPUT | |
| echo "latest_commit_sha=$latest_commit_sha" >> $GITHUB_OUTPUT | |
| build: | |
| name: Build OpenWrt | |
| needs: check_commits | |
| if: github.event_name == 'workflow_dispatch' || needs.check_commits.outputs.new_commits == 'true' | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Install dependencies | |
| run: | | |
| sudo apt remove -y '*cloud*' '*firefox*' '*chrome*' '*dotnet*' '*php*' | |
| sudo apt update -y && sudo apt upgrade -y | |
| sudo apt install -y build-essential clang flex bison g++ gawk gettext libncurses-dev libssl-dev python3-setuptools rsync swig unzip zlib1g-dev file wget llvm | |
| sudo apt autoremove -y && sudo apt clean -y | |
| - name: Checkout remote repository | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ env.REMOTE_REPOSITORY }} | |
| ref: ${{ needs.check_commits.outputs.remote_branch }} | |
| - name: Checkout current repository | |
| uses: actions/checkout@v6 | |
| with: | |
| path: "builder_repo" | |
| - name: Update and install feeds | |
| run: | | |
| ./scripts/feeds update -a | |
| ./scripts/feeds install -a | |
| # run again because sometimes it misses some dependencies | |
| ./scripts/feeds install -a | |
| - name: Setup configuration and custom files | |
| run: | | |
| # delete unneeded folders and patch files with repository info | |
| rm -frv builder_repo/.git builder_repo/.github | |
| for file in $(grep -rl XXXXXX builder_repo/); do echo "Patching: $file"; sed -i 's|XXXXXX/YYYYYY|${{ github.repository }}|g' "$file" || exit 1; done | |
| patch -p1 < builder_repo/attendedsysupgrade-with-GitHub.patch | |
| mv -v builder_repo/files ./ | |
| chmod -v 755 files/usr/bin/upgrade_custom_openwrt files/www/cgi-bin/github_* | |
| mv -v builder_repo/${{ env.CONFIG_FILE }} .config | |
| rm -rfv builder_repo | |
| make defconfig | |
| - name: Build firmware | |
| run: | | |
| make download -j$(nproc) || { | |
| echo "Retrying..." | |
| sleep 60 | |
| make download -j1 V=s | |
| } | |
| make -j$(nproc) || { | |
| echo "Retrying..." | |
| sleep 60 | |
| make -j1 V=s | |
| } | |
| mkdir -p firmware | |
| find ./bin -type f \( -iname 'openwrt-*-sysupgrade.bin' -or -iname 'config.buildinfo' -or -iname 'version.buildinfo' \) -exec mv -v {} ./firmware/ \; ||: | |
| mv .config firmware/full.config ||: | |
| cd firmware && sha256sum openwrt-*-sysupgrade.bin >sha256sums ||: | |
| - name: Upload artifacts | |
| uses: actions/[email protected] | |
| with: | |
| name: gl-mt6000-firmware | |
| path: firmware/* | |
| - name: Create release | |
| run: | | |
| RELEASE_DATE=$(date +%F) | |
| gh release delete "${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE}" --cleanup-tag -y --repo "${{ github.repository }}" ||: | |
| gh release create "${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE}" --repo "${{ github.repository }}" --latest --notes "### 🔄 Main Repository | |
| - **Repository:** [${{ env.REMOTE_REPOSITORY }}](https://github.com/${{ env.REMOTE_REPOSITORY }}) | |
| - **Branch:** ${{ needs.check_commits.outputs.remote_branch }} | |
| - **Commit:** ${{ needs.check_commits.outputs.latest_commit_sha }} | |
| ### 📝 Build Information | |
| - **Target:** [Flint 2 (GL-MT6000)](https://openwrt.org/toh/gl.inet/gl-mt6000) | |
| - **Configuration:** [${{ env.CONFIG_FILE }}](${{ env.CONFIG_FILE }}) | |
| - **WiFi UCODE scripts** | |
| - **Wireguard VPN** | |
| - **Policy Based Routing** | |
| - **Ad Block Fast** | |
| - **REMOVED:** odhcp, upnp, iptables, avahi, samba, usb storage..." --title "OpenWrt Custom Release for Flint 2 (${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE})" firmware/* | |
| - name: Clean up old releases | |
| run: | | |
| # '.[0:10][]' limits to the 10 most recent releases | |
| gh api repos/${{ github.repository }}/releases | jq -r '.[10:][] | "\(.id) \(.tag_name)"' | while read id tag; do | |
| gh api -X DELETE "repos/${{ github.repository }}/releases/$id" && gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" 2>/dev/null ||: | |
| done |