From 7eabb85d0a61eef983d03905d65157969834dc04 Mon Sep 17 00:00:00 2001 From: wu58430 Date: Sun, 9 Jun 2024 20:28:50 +0800 Subject: [PATCH] action --- .github/workflows/build.yml | 38 ++++++++++++++++++ .github/workflows/docker-image.yml | 62 ++++++++++++++++++++---------- 2 files changed, 80 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6b6a780c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +on: #指定触发 workflow 的事件 + push: #当代码推送时触发 + +jobs: #定义工作流程 + build: #工作流名称为 build + runs-on: ubuntu-22.04 #使用 Ubuntu 22.04 环境执行 + container: #定义容器 + image: archlinux:latest #使用 Arch Linux 镜像 + steps: #定义工作流程中的步骤 + - name: Install dependencies + run: | + pacman -Syyu --noconfirm \ + base-devel \ + arm-none-eabi-gcc \ + arm-none-eabi-newlib \ + git \ + python-pip \ + python-crcmod \ + + - name: Checkout #拉取代码 + uses: actions/checkout@v3 #使用 GitHub Actions 提供的 checkout 动作 + + - name: safe.directory #设置 git 的 safe.directory 配置 + run: git config --global --add safe.directory /__w/uv-k5-firmware-custom/uv-k5-firmware-custom + + - name: Make #执行 make 命令 + run: make full #编译项目 + + - name: size #计算 firmware 大小 + run: arm-none-eabi-size firmware #使用 arm-none-eabi-size 命令计算固件大小 + + - name: Upload Artifact #上传固件文件 + uses: actions/upload-artifact@v3 #使用 GitHub Actions 提供的 upload-artifact 动作 + with: + name: firmware #设置 artifact 名称为 firmware + path: LOSEHU*.bin #上传文件路径为 LOSEHU*.bin + + diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8a903073..5fb24425 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,3 @@ - on: #鎸囧畾瑙﹀彂 workflow 鐨勪簨浠 push: #褰撲唬鐮佹帹閫佹椂瑙﹀彂 @@ -16,33 +15,56 @@ jobs: #瀹氫箟宸ヤ綔娴佺▼ arm-none-eabi-newlib \ git \ python-pip \ - python-crcmod + python-crcmod \ + zip \ + lftp \ + python-requests - name: Checkout #鎷夊彇浠g爜 uses: actions/checkout@v3 #浣跨敤 GitHub Actions 鎻愪緵鐨 checkout 鍔ㄤ綔 - name: safe.directory #璁剧疆 git 鐨 safe.directory 閰嶇疆 - run: git config --global --add safe.directory /__w/uv-k5-firmware-chinese/uv-k5-firmware-chinese + run: git config --global --add safe.directory /__w/uv-k5-firmware-custom/uv-k5-firmware-custom - - name: Make #鎵ц make 鍛戒护 - run: make #缂栬瘧椤圭洰 + - name: Generate #鐢熸垚鍥轰欢 + run: | + python gen.py + python genJson.py - - name: size #璁$畻 firmware 澶у皬 - run: arm-none-eabi-size firmware #浣跨敤 arm-none-eabi-size 鍛戒护璁$畻鍥轰欢澶у皬 + - name: Create ZIP file + run: | + mkdir -p output + zip -j output/losehu.zip ./LOSEHU*.bin ./version.json ./function.json - - name: Upload Artifact #涓婁紶鍥轰欢鏂囦欢 + - name: Upload ALL #涓婁紶鍥轰欢鏂囦欢 uses: actions/upload-artifact@v3 #浣跨敤 GitHub Actions 鎻愪緵鐨 upload-artifact 鍔ㄤ綔 with: - name: firmware #璁剧疆 artifact 鍚嶇О涓 firmware - path: LOSEHU*.bin #涓婁紶鏂囦欢璺緞涓 LOSEHU*.bin + name: firmware_all #璁剧疆 artifact 鍚嶇О涓 firmware + path: output/losehu.zip #涓婁紶鏂囦欢璺緞涓 LOSEHU*.bin + + - name: Upload files + run: | + echo "Uploading LOSEHU.zip to ftp" + lftp -u ${{ secrets.FTP_USERNAME }},${{ secrets.FTP_PASSWORD }} ${{ secrets.FTP_SERVER }} <