Auto compile with openwrt sdk #211
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
| # | |
| # Copyright (c) 2022-2025 SMALLPROGRAM <https://github.com/smallprogram> | |
| # Copyright (C) 2026 Openwrt-Passwall Organization | |
| # Description: Auto compile | |
| # | |
| name: "Auto compile with openwrt sdk" | |
| on: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| inputs: | |
| ssh: | |
| description: 'SSH connection to Actions' | |
| required: false | |
| default: 'false' | |
| env: | |
| TZ: Asia/Shanghai | |
| passwall: ${{ github.repository }} | |
| packages: Openwrt-Passwall/openwrt-passwall-packages | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| job_check: | |
| name: Check Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| passwall_version: ${{ steps.check_version.outputs.latest_version }} | |
| has_update: ${{ steps.check_version.outputs.has_update }} | |
| prerelease: ${{ steps.check_version.outputs.prerelease }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@main | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.ref_name }} | |
| - name: Check version | |
| id: check_version | |
| env: | |
| url_tags: https://api.github.com/repos/${{ env.passwall }}/releases/latest | |
| run: | | |
| cd luci-app-passwall | |
| latest_version=$(awk -F ':=' '/^PKG_VERSION:=|^PKG_RELEASE:=/ {print $2}' Makefile | sed ':a;N;s/\$(PKG_VERSION)-//;s/\n$//;s/\n/-/;ba') | |
| echo "latest_version=${latest_version}" >> $GITHUB_OUTPUT | |
| prerelease=$([ "${{ github.ref_name }}" == "main" ] && echo false || echo true) | |
| echo "prerelease=${prerelease}" >> $GITHUB_OUTPUT | |
| remote_latest_version=$(wget -qO- -t1 -T2 ${{env.url_tags}} | jq -r '.tag_name') | |
| if [ -z "$remote_latest_version" ] || [ "$remote_latest_version" = "null" ]; then | |
| echo "Failed to fetch remote tags" | |
| echo "has_update=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "Remote latest: $remote_latest_version" | |
| if [ "$latest_version" = "$remote_latest_version" ]; then | |
| echo "has_update=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_update=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare release | |
| if: steps.check_version.outputs.has_update == 'true' | |
| run: | | |
| echo "" >> release.txt | |
| echo "## :mega: 获取其他软件包 / How to Get Other Packages" >>release.txt | |
| echo "" >>release.txt | |
| echo "### 方式 1:添加软件源 / Method 1: Add Software Source" >>release.txt | |
| echo " * 请按照 [openwrt-passwall-build](https://github.com/moetayuko/openwrt-passwall-build) 仓库的说明,将其提供的软件源添加到设备中,然后直接使用包管理器安装。" >>release.txt | |
| echo " Follow the instructions in the [openwrt-passwall-build](https://github.com/moetayuko/openwrt-passwall-build) repository to add the provided software source to your device, then install directly using the package manager." >>release.txt | |
| echo "" >>release.txt | |
| echo "### 方式 2:手动下载并安装 / Method 2: Manual Download and Install" >>release.txt | |
| echo "" >>release.txt | |
| echo "* 从 [SourceForge](https://sourceforge.net/projects/openwrt-passwall-build/files/) 下载预构建的软件包。" >>release.txt | |
| echo " Download prebuilt packages from [SourceForge](https://sourceforge.net/projects/openwrt-passwall-build/files/)." >>release.txt | |
| echo "" >>release.txt | |
| echo "* 将文件上传到您的设备,使用 Shell 命令进行安装。" >>release.txt | |
| echo " Upload files to your device, install it with shell command." >>release.txt | |
| echo "" >>release.txt | |
| echo "ipk" >>release.txt | |
| echo "\`\`\`" >>release.txt | |
| echo "opkg install /path/to/package.ipk" >>release.txt | |
| echo "\`\`\`" >>release.txt | |
| echo "apk" >>release.txt | |
| echo "\`\`\`" >>release.txt | |
| echo "apk add /path/to/package.apk" >>release.txt | |
| echo "\`\`\`" >>release.txt | |
| echo "" >>release.txt | |
| echo ":warning: 请将 /path/to/package 替换为实际下载的软件包路径。" >>release.txt | |
| echo "- Replace /path/to/package with the actual path of the downloaded packages." >>release.txt | |
| touch release.txt | |
| - name: Generate new tag & release | |
| if: steps.check_version.outputs.has_update == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{steps.check_version.outputs.latest_version}} | |
| target_commitish: ${{ github.ref_name }} | |
| prerelease: ${{steps.check_version.outputs.prerelease}} | |
| body_path: release.txt | |
| job_build_passwall: | |
| name: Build passwall [${{ matrix.ver }}] | |
| needs: job_check | |
| if: needs.job_check.outputs.has_update == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - url_sdk: https://archive.openwrt.org/releases/21.02.7/targets/x86/64/openwrt-sdk-21.02.7-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz | |
| ver: "22.03-" | |
| - url_sdk: https://downloads.openwrt.org/releases/24.10.5/targets/x86/64/openwrt-sdk-24.10.5-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst | |
| ver: "23.05-24.10" | |
| - url_sdk: https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-14.3.0_musl.Linux-x86_64.tar.zst | |
| ver: "25.12+" | |
| steps: | |
| - name: Install packages | |
| run: | | |
| sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /usr/local/lib/android | |
| echo "Install packages" | |
| sudo -E apt-get -qq update | |
| 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 ecj fastjar flex gawk gettext gcc-multilib \ | |
| g++-multilib git gnutls-dev gperf haveged help2man intltool lib32gcc-s1 libc6-dev-i386 libelf-dev \ | |
| libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses-dev libpython3-dev \ | |
| libreadline-dev libssl-dev libtool libyaml-dev libz-dev lld llvm lrzsz mkisofs msmtp nano \ | |
| ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip python3-ply python3-docutils \ | |
| python3-pyelftools qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs \ | |
| upx-ucl unzip vim wget xmlto xxd zlib1g-dev zstd | |
| sudo -E apt-get -qq autoremove --purge | |
| sudo -E apt-get -qq clean | |
| - name: Initialization environment | |
| run: | | |
| wget ${{ matrix.url_sdk }} | |
| file_name=$(echo ${{ matrix.url_sdk }} | awk -F/ '{print $NF}') | |
| mkdir sdk | |
| if [[ $file_name == *.tar.xz ]]; then | |
| tar -xJf $file_name -C ./sdk --strip-components=1 | |
| elif [[ $file_name == *.tar.zst ]]; then | |
| tar --zstd -x -f $file_name -C ./sdk --strip-components=1 | |
| else | |
| echo "Unsupported file format: $file_name" | |
| exit 1 | |
| fi | |
| cd sdk | |
| # Update feeds to github source | |
| sed -i \ | |
| -e 's|git\.openwrt\.org/feed|github.com/openwrt|g' \ | |
| -e 's|git\.openwrt\.org/project|github.com/openwrt|g' \ | |
| -e 's|git\.openwrt\.org/openwrt|github.com/openwrt|g' \ | |
| "feeds.conf.default" | |
| cat > feeds.tmp <<'EOF' | |
| src-git passwall_packages https://github.com/${{ env.packages }}.git;main | |
| src-git passwall https://github.com/${{ env.passwall }}.git;${{ github.ref_name }} | |
| EOF | |
| cat feeds.conf.default >> feeds.tmp | |
| mv feeds.tmp feeds.conf.default | |
| ./scripts/feeds update -a | |
| ./scripts/feeds install -a | |
| - name: Compile | |
| id: compile | |
| run: | | |
| cd sdk | |
| 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 | |
| echo "CONFIG_PACKAGE_luci-app-passwall=m" >> .config | |
| make defconfig | |
| echo "make package/luci-app-passwall/{clean,compile} -j$(nproc)" | |
| make package/luci-app-passwall/{clean,compile} -j$(nproc) V=s | |
| mkdir upload | |
| mv bin/packages/*/passwall/luci-* upload/ | |
| cd upload | |
| for i in $(ls); do mv $i ${{ matrix.ver }}_$i; done | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
| - name: Upload passwall ipks to release | |
| uses: softprops/action-gh-release@v2 | |
| if: steps.compile.outputs.status == 'success' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{needs.job_check.outputs.passwall_version}} | |
| files: ${{ env.FIRMWARE }}/* |