forked from langgenius/dify-official-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (92 loc) · 3.28 KB
/
upload-merged-plugin.yaml
File metadata and controls
105 lines (92 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Upload Merged Plugin
on:
push:
branches:
- main
paths:
- "agent-strategies/**"
- "datasources/**"
- "extensions/**"
- "models/**"
- "tools/**"
- "triggers/**"
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
plugins: ${{ steps.filter.outputs.plugins }}
has_changes: ${{ steps.filter.outputs.has_changes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: filter
name: Detect changed plugins
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
CHANGED_FILES=$(gh pr view -R ${{ github.repository }} ${{ github.event.pull_request.number }} --json files --jq '.files[].path')
else
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
BASE_SHA="HEAD~1"
else
BASE_SHA="${{ github.event.before }}"
fi
CHANGED_FILES=$(git diff --name-only $BASE_SHA HEAD)
fi
MANIFESTS=$(find . -name "manifest.yaml" -not -path "*/.*")
VALID_PLUGINS=()
for m in $MANIFESTS; do
PLUGIN_PATH=$(dirname "$m" | sed 's|^\./||')
if echo "$CHANGED_FILES" | grep -q "^$PLUGIN_PATH/"; then
VALID_PLUGINS+=("$PLUGIN_PATH")
fi
done
if [ ${#VALID_PLUGINS[@]} -eq 0 ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "plugins=[]" >> $GITHUB_OUTPUT
else
JSON=$(printf '%s\n' "${VALID_PLUGINS[@]}" | jq -R . | jq -s -c .)
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "plugins=$JSON" >> $GITHUB_OUTPUT
echo "Detected plugins: $JSON"
fi
upload-merged-plugin:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
plugin_path: ${{ fromJson(needs.detect-changes.outputs.plugins) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Clone Marketplace Toolkit
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
gh repo clone langgenius/dify-marketplace-toolkit -- .scripts/
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12.7
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
activate-environment: false
- name: Download Dify CLI
env:
GH_TOKEN: ${{ secrets.ORG_SCOPE_GITHUB_TOKEN }}
run: |
gh release download -R langgenius/dify-plugin-daemon --pattern "dify-plugin-linux-amd64" --dir .scripts
chmod +x .scripts/dify-plugin-linux-amd64
mv .scripts/dify-plugin-linux-amd64 .scripts/dify
- name: Upload Plugin
run: |
uv run --with requests --with dify_plugin python .scripts/uploader/upload-package.py -d "${{ matrix.plugin_path }}" -t "${{ secrets.MARKETPLACE_TOKEN }}" --plugin-daemon-path .scripts/dify -u "${{ secrets.MARKETPLACE_BASE_URL }}" -f