Skip to content

fix🐛: 修复插件配置读取路径问题 #11

fix🐛: 修复插件配置读取路径问题

fix🐛: 修复插件配置读取路径问题 #11

Workflow file for this run

name: Build and Release Plugin
on:
push:
tags:
- "v*"
branches:
- "**"
paths:
- ".github/workflows/release.yml"
- "src/**"
- "scripts/**"
- "plugin_framework/**"
- "pyproject.toml"
- "plugin.json"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/release.yml"
- "src/**"
- "scripts/**"
- "plugin_framework/**"
- "pyproject.toml"
- "plugin.json"
workflow_dispatch:
jobs:
meta:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
version: ${{ steps.get_tag.outputs.version }}
is_release: ${{ steps.get_tag.outputs.is_release }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag and version
id: get_tag
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
tag=${GITHUB_REF#refs/tags/}
else
tag=$(git describe --tags --match "v*" 2>/dev/null || echo "v0.0.0")
if [[ $tag != v* ]]; then
tag="v0.0.0"
fi
# 添加日期和commit hash作为开发版本标识
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)")
fi
version=${tag#v}
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "is_release=$is_release" >> $GITHUB_OUTPUT
echo "Tag: $tag, Version: $version, Is Release: $is_release"
build:
needs: meta
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.get_filename.outputs.filename }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup uv
uses: astral-sh/setup-uv@v7
- name: Install project
run: |
uv sync --all-extras
- name: Build plugin
run: |
uv run python scripts/build_plugin.py --output dist
- name: Verify build
run: |
echo "=== 构建产物列表 ==="
ls -lh dist/
echo ""
echo "=== ZIP文件内容 ==="
unzip -l dist/*.zip
echo ""
echo "=== 验证plugin.json ==="
unzip -p dist/*.zip */plugin.json | python -m json.tool
- name: Get plugin filename
id: get_filename
run: |
filename=$(ls dist/*.zip | xargs -n 1 basename)
echo "filename=$filename" >> $GITHUB_OUTPUT
echo "Plugin filename: $filename"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_filename.outputs.filename }}
path: dist/*.zip
changelog:
needs: meta
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.generate-changelog.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Generate changelog
id: generate-changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python scripts/generate_changelog.py --latest > CHANGES.md
{
echo 'content<<EOF'
cat CHANGES.md
echo EOF
} >> "$GITHUB_OUTPUT"
echo "✅ Changelog generated"
- name: Commit CHANGELOG
if: ${{ needs.meta.outputs.is_release == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python scripts/generate_changelog.py --output CHANGELOG.md
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .vscode/changelog-pr-authors.json 2>/dev/null || true
git add CHANGELOG.md
git diff --cached --quiet && exit 0
git commit -m "chore🔧: Update CHANGELOG"
git push origin HEAD:${{ github.event.repository.default_branch }}
release:
needs: [meta, build, changelog]
runs-on: ubuntu-latest
if: ${{ needs.meta.outputs.is_release == 'true' }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}
path: dist
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.zip
tag_name: ${{ needs.meta.outputs.tag }}
body: ${{ needs.changelog.outputs.release_body }}
draft: false
prerelease: false