Skip to content

Commit

Permalink
action
Browse files Browse the repository at this point in the history
  • Loading branch information
losehu committed Jun 9, 2024
1 parent 8e19866 commit 7eabb85
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 20 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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


62 changes: 42 additions & 20 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

on: #指定触发 workflow 的事件
push: #当代码推送时触发

Expand All @@ -16,33 +15,56 @@ jobs: #定义工作流程
arm-none-eabi-newlib \
git \
python-pip \
python-crcmod
python-crcmod \
zip \
lftp \
python-requests
- 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-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 }} <<EOF
cd losehu
put output/losehu.zip
bye
EOF

- name: Call API
env:
API_URL: ${{ secrets.API_URL }}
run: |
python -c "
import time
import requests
import os
timestamp = int(time.time())
url = f'{os.getenv('API_URL')}?v={timestamp}'
response = requests.get(url)
if response.status_code == 200:
print('API called successfully')
else:
print(f'Failed to call API: {response.status_code}')"
- name: Upload binaries to release #将二进制文件上传到 release
if: ${{ startsWith(github.ref, 'refs/tags/v') }} #设置条件,当 ref 以 'refs/tags/v' 开头时执行
uses: svenstaro/upload-release-action@v2 #使用 GitHub Actions 提供的 upload-release-action 动作
with:
repo_token: ${{ secrets.GITHUB_TOKEN }} #GitHub token
file: firmware.packed.bin #要上传的文件
asset_name: LoseHu_$tag.bin #上传的文件名
tag: ${{ github.ref }} #GitHub ref
overwrite: true #覆盖已有的文件
release_name: release ${{ github.ref_name }} #发布名称为 release + ref 名称

0 comments on commit 7eabb85

Please sign in to comment.