-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (87 loc) · 3.28 KB
/
package-and-release.yml
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
name: Package and Release
on:
push:
tags:
- "*"
jobs:
package-and-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Install Dify tools
run: |
curl -s https://api.github.com/repos/langgenius/dify-plugin-daemon/releases/latest \
| jq -r ".assets[] | select(.name | test(\"dify-plugin-linux-amd64\")) | .browser_download_url" \
| xargs -n 1 sudo curl -L -o /usr/local/bin/dify
sudo chmod +x /usr/local/bin/dify
- name: Checkout repository
uses: actions/checkout@v4
- name: Add some files/directories to .difyignore
run: |
echo "" >> .difyignore
echo ".git/" >> .difyignore
echo ".github/" >> .difyignore
echo ".devcontainer/" >> .difyignore
echo ".vscode/" >> .difyignore
echo ".gitignore" >> .difyignore
echo ".ruff.toml" >> .difyignore
- name: Replace README.md
run: |
if [ -f "README.difypkg.md" ]; then
mv -f README.difypkg.md README.md
fi
- name: Get the repository directory name
id: get_repo_dir_name
run: |
dir_name=$(basename ${{ github.workspace }})
if [ -z "$dir_name" ]; then
echo "Repository directory not found"
exit 1
fi
echo "dir_name=$dir_name" >> $GITHUB_OUTPUT
- name: Get plugin info from manifest.yaml
id: get_plugin_info
run: |
plugin_author=$(yq -r '.author | select(.)' manifest.yaml)
if [ -z "$plugin_author" ]; then
echo "Plugin author not found in manifest.yaml"
exit 1
fi
plugin_name=$(yq -r '.name | select(.)' manifest.yaml)
if [ -z "$plugin_name" ]; then
echo "Plugin name not found in manifest.yaml"
exit 1
fi
plugin_version=$(yq -r '.version | select(.)' manifest.yaml)
if [ -z "$plugin_version" ]; then
echo "Plugin version not found in manifest.yaml"
exit 1
fi
echo "plugin_author=$plugin_author" >> $GITHUB_OUTPUT
echo "plugin_name=$plugin_name" >> $GITHUB_OUTPUT
echo "plugin_version=$plugin_version" >> $GITHUB_OUTPUT
- name: Package the plugin
id: package
run: |
dir_name="${{ steps.get_repo_dir_name.outputs.dir_name }}"
plugin_name="${{ steps.get_plugin_info.outputs.plugin_author }}-${{ steps.get_plugin_info.outputs.plugin_name }}_${{ steps.get_plugin_info.outputs.plugin_version }}"
plugin_file="../${plugin_name}.difypkg"
echo "Packaging $plugin_name..."
dify plugin package ../$dir_name -o $plugin_file
if [ -f "$plugin_file" ]; then
echo "Plugin packaged successfully"
else
echo "Failed to package the plugin"
exit 1
fi
echo "plugin_file=$plugin_file" >> $GITHUB_OUTPUT
- name: Relase
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.package.outputs.plugin_file }}