From 997bf44235436e0c4b7fc42a0c49230147fc41b5 Mon Sep 17 00:00:00 2001 From: fujr Date: Wed, 9 Apr 2025 02:57:54 +0800 Subject: [PATCH] add auto compile workflow --- .github/workflows/arm64_apk.env | 4 + .github/workflows/arm64_ipk.env | 4 + .github/workflows/luci.patch | 45 ++++++ .github/workflows/main.yml | 178 +++++++++++++++++++++++ .github/workflows/mipsel.env | 3 + .github/workflows/openwrt_package.config | 11 ++ .github/workflows/qmodem_package_arch | 2 + .github/workflows/qmodem_package_generic | 4 + .github/workflows/x64.env | 3 + 9 files changed, 254 insertions(+) create mode 100644 .github/workflows/arm64_apk.env create mode 100644 .github/workflows/arm64_ipk.env create mode 100644 .github/workflows/luci.patch create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/mipsel.env create mode 100644 .github/workflows/openwrt_package.config create mode 100644 .github/workflows/qmodem_package_arch create mode 100644 .github/workflows/qmodem_package_generic create mode 100644 .github/workflows/x64.env diff --git a/.github/workflows/arm64_apk.env b/.github/workflows/arm64_apk.env new file mode 100644 index 0000000..c1dc864 --- /dev/null +++ b/.github/workflows/arm64_apk.env @@ -0,0 +1,4 @@ +SDK_NAME=openwrt-sdk-mvebu-cortexa53_gcc-13.3.0_musl.Linux-x86_64 +SDK_EXT=tar.zst +SDK_URL=https://downloads.openwrt.org/snapshots/targets/mvebu/cortexa53/ +SDK_ARCH=aarch64_cortex-a53 diff --git a/.github/workflows/arm64_ipk.env b/.github/workflows/arm64_ipk.env new file mode 100644 index 0000000..db817a7 --- /dev/null +++ b/.github/workflows/arm64_ipk.env @@ -0,0 +1,4 @@ +SDK_NAME=openwrt-sdk-23.05.5-mvebu-cortexa53_gcc-12.3.0_musl.Linux-x86_64 +SDK_EXT=tar.xz +SDK_URL=https://downloads.openwrt.org/releases/23.05.5/targets/mvebu/cortexa53/ +SDK_ARCH=aarch64_cortex-a53 diff --git a/.github/workflows/luci.patch b/.github/workflows/luci.patch new file mode 100644 index 0000000..83a1346 --- /dev/null +++ b/.github/workflows/luci.patch @@ -0,0 +1,45 @@ +From 55db7a1f7f650f965e783301387246f9f62fa1ec Mon Sep 17 00:00:00 2001 +From: Liangbin Lian +Date: Wed, 11 Dec 2024 11:20:45 +0800 +Subject: [PATCH] luci.mk: postinst compat openwrt 23 + +--- + luci.mk | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/luci.mk b/luci.mk +index aca52e08cd..b28284c892 100644 +--- a/luci.mk ++++ b/luci.mk +@@ -53,6 +53,8 @@ LUCI_LANG.uk=Українська (Ukrainian) + LUCI_LANG.vi=Tiếng Việt (Vietnamese) + LUCI_LANG.zh_Hans=简体中文 (Chinese Simplified) + LUCI_LANG.zh_Hant=繁體中文 (Chinese Traditional) ++LUCI_LANG.zh-cn=$(LUCI_LANG.zh_Hans) ++LUCI_LANG.zh-tw=$(LUCI_LANG.zh_Hant) + + # Submenu titles + LUCI_MENU.col=1. Collections +@@ -211,8 +213,8 @@ endef + ifndef Package/$(PKG_NAME)/postinst + define Package/$(PKG_NAME)/postinst + [ -n "$${IPKG_INSTROOT}" ] || {$(foreach script,$(LUCI_DEFAULTS), +- (. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script)) +- rm -f /tmp/luci-indexcache ++ [ -f /etc/uci-defaults/$(script) ] && (. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script)) ++ rm -f /tmp/luci-indexcache /tmp/luci-indexcache.* + rm -rf /tmp/luci-modulecache/ + killall -HUP rpcd 2>/dev/null + exit 0 +@@ -325,7 +327,7 @@ define LuciTranslation + + define Package/luci-i18n-$(LUCI_BASENAME)-$(1)/postinst + [ -n "$$$${IPKG_INSTROOT}" ] || { +- (. /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)) && rm -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1) ++ [ -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1) ] && (. /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)) && rm -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1) + exit 0 + } + endef +-- +2.46.0 + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0b40ff7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,178 @@ +name: "Auto compile with OpenWrt SDK" +on: + workflow_dispatch: + push: + paths: + - 'qmodem/luci/luci-app-qmodem/Makefile' + +env: + TZ: Asia/Shanghai + +jobs: + job_prepare: + name: Prepare + runs-on: ubuntu-latest + outputs: + git_tag: ${{ steps.set_git_tag.outputs.git_tag }} + is_latest: ${{ steps.cache-version.outputs.cache-hit }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: 'qmodem' + + - name: Set git tag + id: set_git_tag + run: | + pkg_version=$(grep -oP '^PKG_VERSION:=\K.*' qmodem/luci/luci-app-qmodem/Makefile) + if [ -z "$pkg_version" ]; then + echo "PKG_VERSION not found in Makefile" + exit 1 + fi + echo "Extracted PKG_VERSION: $pkg_version" + tag="v$pkg_version" + echo "git_tag=$tag" >> $GITHUB_OUTPUT + echo "git_tag=$tag" + echo "git_tag=$tag" >> cache-version + + - name: Cache Version + id: cache-version + uses: actions/cache@v3 + with: + path: cache-version + key: qmodem-version + + job_build_qmodem: + name: Build QModem + needs: job_prepare + continue-on-error: true + strategy: + matrix: + build_arch: ['arm64_ipk',"arm64_apk"] + runs-on: ubuntu-latest + steps: + - name: Install packages + run: | + sudo -E apt-get -qq update + sudo -E apt-get -qq install zstd build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-venv rsync unzip zlib1g-dev file wget + sudo -E apt-get -qq autoremove --purge + sudo -E apt-get -qq clean + + + - name: Checkout + uses: actions/checkout@v2 + with: + path: 'qmodem' + + + - name: Import Env + run: cat qmodem/.github/workflows/${{ matrix.build_arch }}.env >> "$GITHUB_ENV" + + - name: Cache openwrt SDK + id: cache-sdk + uses: actions/cache@v3 + with: + path: sdk + key: openwrt-sdk-${{ matrix.build_arch }} + + - name: Initialization environment + if: steps.cache-sdk.outputs.cache-hit != 'true' + env: + url_sdk: ${{ env.SDK_URL }}${{ env.SDK_NAME}}.${{ env.SDK_EXT }} + run: | + wget ${{ env.url_sdk }} + file_name=${{ env.SDK_NAME}}.${{ env.SDK_EXT }} + if [ "${{ env.SDK_EXT }}" == "tar.zst" ]; then + mkdir sdk && tar --zstd -xvf $file_name -C ./sdk --strip-components=1 + elif [ "${{ env.SDK_EXT }}" == "tar.xz" ]; then + mkdir sdk && tar -xvf $file_name -C ./sdk --strip-components=1 + fi + cd sdk + echo "src-git base https://github.com/openwrt/openwrt.git;main" > feeds.conf + echo "src-git packages https://github.com/openwrt/packages.git;master" >> feeds.conf + echo "src-git luci https://github.com/openwrt/luci.git;master" >> feeds.conf + echo "src-git routing https://git.openwrt.org/feed/routing.git;master" >> feeds.conf + ./scripts/feeds update -a + ./scripts/feeds install -a + cd .. + echo "src-link qmodem `pwd`/qmodem" >> sdk/feeds.conf + cd sdk + ./scripts/feeds update qmodem + ./scripts/feeds install -a -p qmodem + echo "CONFIG_ALL_NONSHARED=n" > .config + echo "CONFIG_ALL_KMODS=n" >> .config + echo "CONFIG_ALL=n" >> .config + echo "CONFIG_AUTOREMOVE=n" >> .config + echo "CONFIG_LUCI_LANG_zh_Hans=y" >> .config + cat ../qmodem/.github/workflows/openwrt_package.config >> .config + make defconfig + make download -j$(nproc) || true + + - name: Compile QModem + id: compile + run: | + cd sdk + ./scripts/feeds update qmodem + ./scripts/feeds install -a -p qmodem + generic_package=$(cat ../qmodem/.github/workflows/qmodem_package_generic) + arch_package=$(cat ../qmodem/.github/workflows/qmodem_package_arch) + for package in $generic_package; do + make package/$package/compile -j$(nproc) || true + done + for package in $arch_package; do + make package/$package/compile -j$(nproc) || true + done + ls bin/packages/${{ env.SDK_ARCH }}/qmodem/ + echo "status=success" >> $GITHUB_OUTPUT + echo "FIRMWARE=$(pwd)/bin/packages/${{ env.SDK_ARCH }}/qmodem/" >> $GITHUB_ENV + + - name: Upload QModem + if: ${{ steps.compile.outputs.status == 'success' }} + uses: actions/upload-artifact@v4 + with: + name: QModem-${{ matrix.build_arch }} + path: ${{ env.FIRMWARE }}* + retention-days: 7 + + job_release_artifacts: + name: Release Artifacts + needs: [job_build_qmodem, job_prepare] + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Create releases directory + run: mkdir -p releases + + - name: Package artifacts into tar.gz + run: | + for dir in artifacts/*; do + if [ -d "$dir" ]; then + base_name=$(basename "$dir") + tar -czf "releases/${base_name}.tar.gz" -C "$dir" . + fi + done + + - name: Check Release type + run: | + if [[ "${GITHUB_REF}" == *"-beta" ]]; then + echo "Release type: beta" + echo "RELEASE_TYPE=beta" >> $GITHUB_ENV + elif [[ "${GITHUB_REF}" == *"-rc" ]]; then + echo "Release type: rc" + echo "RELEASE_TYPE=rc" >> $GITHUB_ENV + else + echo "Release type: release" + echo "RELEASE_TYPE=release" >> $GITHUB_ENV + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + if: ${{ needs.job_prepare.outputs.is_latest == 'true' }} + with: + tag_name: ${{ needs.job_prepare.outputs.git_tag }} + prerelease: false + files: releases/* diff --git a/.github/workflows/mipsel.env b/.github/workflows/mipsel.env new file mode 100644 index 0000000..c511827 --- /dev/null +++ b/.github/workflows/mipsel.env @@ -0,0 +1,3 @@ +SDK_NAME=openwrt-sdk-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64 +SDK_URL=https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/ +SDK_ARCH=mipsel_24kc diff --git a/.github/workflows/openwrt_package.config b/.github/workflows/openwrt_package.config new file mode 100644 index 0000000..82132d2 --- /dev/null +++ b/.github/workflows/openwrt_package.config @@ -0,0 +1,11 @@ +CONFIG_PACKAGE_luci-app-qmodem=m +CONFIG_PACKAGE_luci-app-qmodem_USE_TOM_CUSTOMIZED_QUECTEL_CM=m +CONFIG_PACKAGE_luci-app-qmodem-mwan=m +CONFIG_PACKAGE_luci-app-qmodem-sms=m +CONFIG_PACKAGE_luci-app-qmodem-ttl=m +CONFIG_PACKAGE_luci-i18n-qmodem-mwan-zh-cn=m +CONFIG_PACKAGE_luci-i18n-qmodem-ru=m +CONFIG_PACKAGE_luci-i18n-qmodem-sms-zh-cn=m +CONFIG_PACKAGE_luci-i18n-qmodem-zh-cn=m +CONFIG_PACKAGE_tom_modem=m +CONFIG_PACKAGE_quectel-CM-5G-M=m diff --git a/.github/workflows/qmodem_package_arch b/.github/workflows/qmodem_package_arch new file mode 100644 index 0000000..3989ca1 --- /dev/null +++ b/.github/workflows/qmodem_package_arch @@ -0,0 +1,2 @@ +tom_modem +quectel_CM_5G diff --git a/.github/workflows/qmodem_package_generic b/.github/workflows/qmodem_package_generic new file mode 100644 index 0000000..20c6b77 --- /dev/null +++ b/.github/workflows/qmodem_package_generic @@ -0,0 +1,4 @@ +luci-app-qmodem +luci-app-qmodem-sms +luci-app-qmodem-mwan +luci-app-qmodem-ttl diff --git a/.github/workflows/x64.env b/.github/workflows/x64.env new file mode 100644 index 0000000..f62b00c --- /dev/null +++ b/.github/workflows/x64.env @@ -0,0 +1,3 @@ +SDK_NAME=openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64 +SDK_URL=https://downloads.openwrt.org/snapshots/targets/x86/64/ +SDK_ARCH=x86_64