Update Makefile #85
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: Advanced Build and Release for PeDitXOS | |
| # تریگرها | |
| on: | |
| # اجرای دستی با قابلیت دیباگ از طریق SSH | |
| workflow_dispatch: | |
| inputs: | |
| ssh: | |
| description: 'SSH connection to Actions for debugging' | |
| required: false | |
| default: 'false' | |
| type: 'boolean' | |
| # اجرا در زمان پوش به شاخه main | |
| push: | |
| branches: | |
| - 'main' | |
| # --- Granting write permissions to the workflow --- | |
| permissions: | |
| contents: write | |
| env: | |
| TZ: Asia/Tehran | |
| # نام پوشه پکیج شما | |
| REPO_NAME: luci-app-peditxos | |
| jobs: | |
| # --- جاب اول: بررسی نسخه و ساخت Release --- | |
| check_and_release: | |
| name: Check Version and Create Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_version_tag: ${{ steps.check_version.outputs.new_version_tag }} | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| run_build: ${{ steps.check_version.outputs.run_build }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check for new version | |
| id: check_version | |
| run: | | |
| # خواندن نسخه از Makefile داخل پوشه پکیج | |
| MAKEFILE_PATH="${{ env.REPO_NAME }}/Makefile" | |
| if [ ! -f "$MAKEFILE_PATH" ]; then | |
| echo "Makefile not found at $MAKEFILE_PATH" | |
| exit 1 | |
| fi | |
| # Using awk instead of cut for multi-character delimiter | |
| PKG_VERSION=$(grep -m 1 'PKG_VERSION:=' "$MAKEFILE_PATH" | awk -F':=' '{print $2}' | xargs) | |
| PKG_RELEASE=$(grep -m 1 'PKG_RELEASE:=' "$MAKEFILE_PATH" | awk -F':=' '{print $2}' | xargs) | |
| CURRENT_TAG="v${PKG_VERSION}-${PKG_RELEASE}" | |
| echo "Current version from Makefile: ${CURRENT_TAG}" | |
| # بررسی وجود تگ در ریپازیتوری | |
| if git rev-parse "${CURRENT_TAG}" >/dev/null 2>&1; then | |
| echo "Tag ${CURRENT_TAG} already exists. No new build needed." | |
| echo "run_build=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "New version detected: ${CURRENT_TAG}. Proceeding with build." | |
| echo "run_build=true" >> $GITHUB_OUTPUT | |
| echo "new_version_tag=${CURRENT_TAG}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create new release | |
| id: create_release | |
| if: steps.check_version.outputs.run_build == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.check_version.outputs.new_version_tag }} | |
| name: Release ${{ steps.check_version.outputs.new_version_tag }} | |
| body: "Automated release for PeDitXOS Tools. IPK files for various architectures are attached." | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # --- جاب دوم: کامپایل پکیج برای معماریهای مختلف --- | |
| build_package: | |
| name: Build for ${{ matrix.arch }} | |
| needs: check_and_release | |
| if: needs.check_and_release.outputs.run_build == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # --- Using the exact SDK URLs for OpenWrt 24.10 --- | |
| include: | |
| - arch: "x86_64" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/x86/64/openwrt-sdk-24.10.0-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "aarch64_generic" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/rockchip/armv8/openwrt-sdk-24.10.0-rockchip-armv8_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "aarch64_cortex-a53" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/mvebu/cortexa53/openwrt-sdk-24.10.0-mvebu-cortexa53_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "aarch64_cortex-a72" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/mvebu/cortexa72/openwrt-sdk-24.10.0-mvebu-cortexa72_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a5_vfpv4" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/at91/sama5/openwrt-sdk-24.10.0-at91-sama5_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a7" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/mediatek/mt7629/openwrt-sdk-24.10.0-mediatek-mt7629_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a7_neon-vfpv4" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/sunxi/cortexa7/openwrt-sdk-24.10.0-sunxi-cortexa7_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a8_vfpv3" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/sunxi/cortexa8/openwrt-sdk-24.10.0-sunxi-cortexa8_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a9" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/bcm53xx/generic/openwrt-sdk-24.10.0-bcm53xx-generic_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a9_neon" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/zynq/generic/openwrt-sdk-24.10.0-zynq-generic_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a9_vfpv3-d16" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/mvebu/cortexa9/openwrt-sdk-24.10.0-mvebu-cortexa9_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "arm_cortex-a15_neon-vfpv4" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/ipq806x/generic/openwrt-sdk-24.10.0-ipq806x-generic_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "mips_24kc" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/ath79/generic/openwrt-sdk-24.10.0-ath79-generic_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "mips_4kec" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/realtek/rtl838x/openwrt-sdk-24.10.0-realtek-rtl838x_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "mips_mips32" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/bcm53xx/generic/openwrt-sdk-24.10.0-bcm53xx-generic_gcc-13.3.0_musl_eabi.Linux-x86_64.tar.zst" | |
| - arch: "mipsel_24kc" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/ramips/rt288x/openwrt-sdk-24.10.0-ramips-rt288x_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "mipsel_74kc" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/ramips/rt3883/openwrt-sdk-24.10.0-ramips-rt3883_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| - arch: "mipsel_mips32" | |
| sdk_url: "https://downloads.openwrt.org/releases/24.10.0/targets/bcm47xx/generic/openwrt-sdk-24.10.0-bcm47xx-generic_gcc-13.3.0_musl.Linux-x86_64.tar.zst" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential clang flex bison g++ gawk gcc-multilib g++-multilib \ | |
| gettext git libncurses5-dev libssl-dev python3 python3-pip rsync unzip zlib1g-dev file wget zstd | |
| sudo apt-get -qq autoremove --purge && sudo apt-get -qq clean | |
| # --- *** FIX: Installing Python prerequisites using pip *** --- | |
| - name: Install Python dependencies | |
| run: | | |
| python3 -m pip install pyelftools | |
| - name: Cache OpenWrt SDK | |
| id: cache-sdk | |
| uses: actions/cache@v4 | |
| with: | |
| path: openwrt-sdk | |
| key: openwrt-sdk-24.10.0-${{ matrix.arch }} | |
| - name: Download and setup OpenWrt SDK | |
| if: steps.cache-sdk.outputs.cache-hit != 'true' | |
| run: | | |
| # Handling .zst files | |
| wget -q -O openwrt-sdk.tar.zst "${{ matrix.sdk_url }}" | |
| mkdir -p openwrt-sdk | |
| tar --zstd -xf openwrt-sdk.tar.zst -C openwrt-sdk --strip-components=1 | |
| - name: SSH connection for debugging | |
| if: github.event.inputs.ssh == 'true' | |
| uses: mxschmitt/action-tmate@v3 | |
| - name: Compile the package | |
| id: compile | |
| run: | | |
| SDK_PATH=$PWD/openwrt-sdk | |
| # کپی کردن فقط پوشه پکیج به داخل SDK | |
| cp -r $GITHUB_WORKSPACE/$REPO_NAME $SDK_PATH/package/ | |
| cd $SDK_PATH | |
| ./scripts/feeds update -a | |
| ./scripts/feeds install -a | |
| make defconfig | |
| make package/$REPO_NAME/compile -j$(nproc) | |
| # پیدا کردن مسیر فایل ipk و ذخیره آن برای مرحله بعد | |
| IPK_PATH=$(find $PWD/bin/packages -type f -name "${{ env.REPO_NAME }}*.ipk") | |
| echo "ipk_path=${IPK_PATH}" >> $GITHUB_OUTPUT | |
| - name: Upload IPK to the release | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ needs.check_and_release.outputs.upload_url }} | |
| asset_path: ${{ steps.compile.outputs.ipk_path }} | |
| asset_name: ${{ env.REPO_NAME }}_${{ needs.check_and_release.outputs.new_version_tag }}_${{ matrix.arch }}.ipk | |
| asset_content_type: application/vnd.debian.binary-package | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |