Skip to content

更新 manifest.json #3

更新 manifest.json

更新 manifest.json #3

name: 打包扩展
on:
push:
branches:
- main
- test-auto-pack
paths:
- 'EXTENSION/manifest.json'
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Node.js 环境
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: 读取当前版本
id: get_version
run: |
VERSION=$(jq -r '.version' EXTENSION/manifest.json)
echo "[INFO] 当前版本: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: 比较版本
id: compare_versions
run: |
# 仅在 push 事件中执行版本检查
if [ "${{ github.event_name }}" == "push" ]; then
PREV_VERSION=$(git show HEAD~1:EXTENSION/manifest.json | jq -r '.version')
echo "[INFO] 之前的版本: $PREV_VERSION"
if [ "$VERSION" != "$PREV_VERSION" ]; then
echo "[INFO] 版本已变化,正在打包扩展..."
zip -r EXTENSION.zip EXTENSION
echo "[INFO] 打包完成。"
echo "CHANGE=true" >> $GITHUB_ENV
else
echo "[WARN] 版本没有变化。"
echo "CHANGE=false" >> $GITHUB_ENV
fi
else
# 手动触发时跳过版本检查
echo "[INFO] 手动触发,跳过版本检查。"
zip -r EXTENSION.zip EXTENSION
echo "CHANGE=true" >> $GITHUB_ENV
fi
- name: 上传打包文件
if: env.CHANGE == 'true'
uses: actions/upload-artifact@v3
with:
name: extension-zip
path: EXTENSION.zip