Skip to content

pref: 只要扩展有修改就重新打包 #8

pref: 只要扩展有修改就重新打包

pref: 只要扩展有修改就重新打包 #8

name: 打包扩展
on:
push:
branches:
- main
paths:
- 'EXTENSION/**'
workflow_dispatch:
jobs:
package-extension:
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] 版本已变化"
echo "CHANGE=true" >> $GITHUB_ENV
else
echo "[WARN] 版本没有变化。"
echo "CHANGE=false" >> $GITHUB_ENV
fi
else
# 手动触发时跳过版本检查
echo "[INFO] 手动触发,跳过版本检查。"
echo "CHANGE=true" >> $GITHUB_ENV
fi
- name: 上传打包文件
# 在Summary页最下方
if: env.CHANGE == 'true'
uses: actions/upload-artifact@v4
with:
name: extension
path: .\EXTENSION\*