Add plugin release workflow with version extraction and changelog management
Co-authored-by: Fu-Jie <33599649+Fu-Jie@users.noreply.github.com>
This commit is contained in:
141
.github/workflows/plugin-version-check.yml
vendored
Normal file
141
.github/workflows/plugin-version-check.yml
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
# GitHub Actions Workflow for Plugin Version Change Detection
|
||||
# 插件版本变化检测工作流
|
||||
#
|
||||
# This workflow detects version changes in plugins when PRs are created or updated.
|
||||
# 此工作流在创建或更新 PR 时检测插件的版本变化。
|
||||
#
|
||||
# What it does:
|
||||
# 1. Compares plugin versions between base and head branches
|
||||
# 2. Generates a summary of version changes
|
||||
# 3. Comments on the PR with the changes (optional)
|
||||
|
||||
name: Plugin Version Check / 插件版本检查
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'plugins/**/*.py'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check-versions:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout PR head
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
path: head
|
||||
|
||||
- name: Checkout base branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.base.sha }}
|
||||
path: base
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Extract and compare versions
|
||||
id: compare
|
||||
run: |
|
||||
# Extract base versions
|
||||
cd base
|
||||
if [ -f scripts/extract_plugin_versions.py ]; then
|
||||
python scripts/extract_plugin_versions.py --json --output ../base_versions.json
|
||||
else
|
||||
# Fallback if script doesn't exist in base
|
||||
echo "[]" > ../base_versions.json
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# Extract head versions
|
||||
cd head
|
||||
python scripts/extract_plugin_versions.py --json --output ../head_versions.json
|
||||
|
||||
# Compare versions
|
||||
python scripts/extract_plugin_versions.py --compare ../base_versions.json --output ../changes.md
|
||||
cd ..
|
||||
|
||||
echo "=== Version Changes ==="
|
||||
cat changes.md
|
||||
|
||||
# Check if there are any changes
|
||||
if grep -q "No changes detected" changes.md; then
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Store changes for comment
|
||||
{
|
||||
echo 'changes<<EOF'
|
||||
cat changes.md
|
||||
echo 'EOF'
|
||||
} >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Comment on PR
|
||||
if: steps.compare.outputs.has_changes == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const changes = `${{ steps.compare.outputs.changes }}`;
|
||||
|
||||
const body = `## 🔍 Plugin Version Changes / 插件版本变化
|
||||
|
||||
${changes}
|
||||
|
||||
---
|
||||
*This comment was generated automatically. / 此评论由自动生成。*
|
||||
`;
|
||||
|
||||
// Find existing comment from github-actions bot
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
});
|
||||
|
||||
const botComment = comments.find(comment =>
|
||||
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
|
||||
comment.body.includes('Plugin Version Changes')
|
||||
);
|
||||
|
||||
if (botComment) {
|
||||
// Update existing comment
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: botComment.id,
|
||||
body: body,
|
||||
});
|
||||
} else {
|
||||
// Create new comment
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: body,
|
||||
});
|
||||
}
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "## 🔍 Plugin Version Check Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ "${{ steps.compare.outputs.has_changes }}" = "true" ]; then
|
||||
echo "✅ **Version changes detected!**" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
cat changes.md >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "ℹ️ **No version changes detected.**" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
167
.github/workflows/release.yml
vendored
Normal file
167
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
# GitHub Actions Workflow for Plugin Release
|
||||
# 插件发布工作流
|
||||
#
|
||||
# This workflow automates the release process for OpenWebUI plugins.
|
||||
# 此工作流自动化 OpenWebUI 插件的发布流程。
|
||||
#
|
||||
# Triggers:
|
||||
# - Manual trigger (workflow_dispatch) with custom release notes
|
||||
# - Push of version tags (v*)
|
||||
#
|
||||
# What it does:
|
||||
# 1. Scans all plugins for version information
|
||||
# 2. Generates release notes with plugin versions
|
||||
# 3. Creates a GitHub Release with the changelog
|
||||
|
||||
name: Plugin Release / 插件发布
|
||||
|
||||
on:
|
||||
# Manual trigger with inputs
|
||||
# 手动触发并提供输入
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version (e.g., v1.0.0)'
|
||||
required: true
|
||||
type: string
|
||||
release_title:
|
||||
description: 'Release title (optional)'
|
||||
required: false
|
||||
type: string
|
||||
release_notes:
|
||||
description: 'Additional release notes (Markdown)'
|
||||
required: false
|
||||
type: string
|
||||
prerelease:
|
||||
description: 'Mark as pre-release'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
# Trigger on version tags
|
||||
# 版本标签触发
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Determine version
|
||||
id: version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
VERSION="${{ github.event.inputs.version }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Release version: $VERSION"
|
||||
|
||||
- name: Extract plugin versions
|
||||
id: plugins
|
||||
run: |
|
||||
# Run the version extraction script
|
||||
python scripts/extract_plugin_versions.py --json --output plugin_versions.json
|
||||
python scripts/extract_plugin_versions.py --markdown --output plugin_table.md
|
||||
|
||||
# Output for debugging
|
||||
echo "=== Plugin Versions (JSON) ==="
|
||||
cat plugin_versions.json
|
||||
echo ""
|
||||
echo "=== Plugin Versions (Markdown) ==="
|
||||
cat plugin_table.md
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
TITLE="${{ github.event.inputs.release_title }}"
|
||||
NOTES="${{ github.event.inputs.release_notes }}"
|
||||
|
||||
# Generate release notes header with version
|
||||
echo "# ${VERSION} Release / 发布" > release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
|
||||
# Add custom title if provided
|
||||
if [ -n "$TITLE" ]; then
|
||||
echo "## $TITLE" >> release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
fi
|
||||
|
||||
# Add custom notes if provided
|
||||
if [ -n "$NOTES" ]; then
|
||||
echo "## Release Notes / 发布说明" >> release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
echo "$NOTES" >> release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
fi
|
||||
|
||||
# Add plugin versions table
|
||||
echo "## Plugin Versions / 插件版本" >> release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
cat plugin_table.md >> release_notes.md
|
||||
echo "" >> release_notes.md
|
||||
|
||||
# Add installation instructions
|
||||
cat >> release_notes.md << 'INSTALL_INSTRUCTIONS'
|
||||
|
||||
## Installation / 安装
|
||||
|
||||
### From OpenWebUI Community
|
||||
1. Open OpenWebUI Admin Panel
|
||||
2. Navigate to Functions/Tools
|
||||
3. Search for the plugin name
|
||||
4. Click Install
|
||||
|
||||
### Manual Installation / 手动安装
|
||||
1. Download the plugin file (`.py`)
|
||||
2. Open OpenWebUI Admin Panel → Functions
|
||||
3. Click "Create Function" → Import
|
||||
4. Paste the plugin code
|
||||
|
||||
---
|
||||
|
||||
📚 [Documentation / 文档](https://fu-jie.github.io/awesome-openwebui/)
|
||||
🐛 [Report Issues / 报告问题](https://github.com/Fu-Jie/awesome-openwebui/issues)
|
||||
|
||||
INSTALL_INSTRUCTIONS
|
||||
|
||||
echo "=== Release Notes ==="
|
||||
cat release_notes.md
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
name: ${{ github.event.inputs.release_title || steps.version.outputs.version }}
|
||||
body_path: release_notes.md
|
||||
prerelease: ${{ github.event.inputs.prerelease || false }}
|
||||
files: |
|
||||
plugin_versions.json
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "## 🚀 Release Created Successfully!" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Plugin Versions" >> $GITHUB_STEP_SUMMARY
|
||||
cat plugin_table.md >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user