name: rk on: workflow_dispatch: inputs: profile: description: '手动输入的多个 profile,并按逗号分隔' required: true default: 'friendlyarm_nanopi-r3s,radxa_zero-3e' rootfs_partsize: description: '设置根文件系统分区大小 (MB)' required: true default: '1024' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set executable permissions run: chmod +x ${{ github.workspace }}/rockchip/build.sh - name: Setup Docker and Build run: | profiles="${{ github.event.inputs.profile }}" rootfs_partsize="${{ github.event.inputs.rootfs_partsize }}" IFS=',' read -r -a profile_array <<< "$profiles" for profile in "${profile_array[@]}"; do echo "Building for profile: $profile" docker run --rm -i \ --user root \ -v "${{ github.workspace }}/bin:/home/build/immortalwrt/bin" \ -v "${{ github.workspace }}/files:/home/build/immortalwrt/files" \ -v "${{ github.workspace }}/rockchip/imm.config:/home/build/immortalwrt/.config" \ -v "${{ github.workspace }}/rockchip/build.sh:/home/build/immortalwrt/build.sh" \ -e PROFILE=$profile \ -e ROOTFS_PARTSIZE=$rootfs_partsize \ immortalwrt/imagebuilder:rockchip-armv8-openwrt-24.10 /bin/bash /home/build/immortalwrt/build.sh done - name: Locate squashfs firmware files id: locate_files run: | # 查找符合条件的固件文件 firmware_files=$(find "${{ github.workspace }}/bin" -type f -name '*squashfs*.img.gz') # 如果有多个固件文件,按空格分割路径并保存为环境变量 firmware_files_array=($firmware_files) # 输出找到的固件文件路径 echo "Found firmware files: ${firmware_files}" # 临时复制文件到一个平级目录(避免目录结构太复杂) temp_dir="${{ github.workspace }}/firmware_temp" mkdir -p $temp_dir # 将固件文件复制到 temp_dir 目录 cp "${firmware_files_array[@]}" $temp_dir # 将所有固件文件路径合并为一个tar包 tar_file="firmware_files.tar.gz" tar -czf $tar_file -C $temp_dir . # 使用 -C 指定目录,打包该目录下的所有文件,而不包含目录结构 # 将tar包路径设置为环境变量 echo "TAR_FILE=$tar_file" >> $GITHUB_ENV - name: Set release date and tag name id: set_release_info run: | # 设置北京时间 TZ="Asia/Shanghai" date release_date=$(TZ="Asia/Shanghai" date +'%Y-%m-%d %H:%M') tag_name=$(TZ="Asia/Shanghai" date +'%Y%m%d%H%M') echo "Release date: $release_date" echo "Release tag name: $tag_name" echo "RELEASE_DATE=$release_date" >> $GITHUB_ENV echo "TAG_NAME=$tag_name" >> $GITHUB_ENV - name: Create GitHub Release id: create_release uses: ncipollo/release-action@v1.14.0 # 使用 ncipollo/release-action 创建发布 with: tag: ${{ env.TAG_NAME }} # 使用时间戳作为 tag 名称 name: "${{ env.RELEASE_DATE }} Build" # 使用时间戳作为 release 名称 draft: false prerelease: false generateReleaseNotes: false makeLatest: true # 设置为 true token: ${{ secrets.GITHUB_TOKEN }} - name: Upload compressed firmware tarball to GitHub Release uses: actions/upload-release-asset@v1 with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ${{ env.TAR_FILE }} # 上传打包的tar.gz文件 asset_name: firmware_files.tar.gz # 固件压缩包的名称 asset_content_type: application/gzip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}