diff --git a/.github/workflows/pre-check-plugin.yaml b/.github/workflows/pre-check-plugin.yaml index e50ae8c..2662a0d 100644 --- a/.github/workflows/pre-check-plugin.yaml +++ b/.github/workflows/pre-check-plugin.yaml @@ -74,12 +74,37 @@ jobs: - name: Check Plugin Manifest run: | - # manifest.yaml author must be langgenius + # manifest.yaml author must not be langgenius if yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml | grep -q "langgenius"; then echo "!!! Plugin manifest.yaml author must not be 'langgenius'" exit 1 fi + # author must equal to the pr author (lowercase) + if [ "$(yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml)" != "$(gh pr view -R ${{ env.REPO_NAME }} ${{ github.event.pull_request.number }} --json author --jq .author.login | tr '[:upper:]' '[:lower:]')" ]; then + echo "!!! Plugin manifest.yaml author should be lowercase and must be the same as the PR author" + exit 1 + fi + + - name: Check If Version Exists + run: | + # get version, author, name + VERSION=$(yq '.version' ${{ env.PLUGIN_PATH }}/manifest.yaml) + AUTHOR=$(yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml) + NAME=$(yq '.name' ${{ env.PLUGIN_PATH }}/manifest.yaml) + echo "Checking plugin version: $VERSION" + + # Check if the version already exists + RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION") + + if [ "$RESPONSE_CODE" = "200" ]; then + RESPONSE=$(curl -s "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION") + if [ "$(echo "$RESPONSE" | jq -r '.code')" = "0" ]; then + echo "!!! Plugin version $VERSION already exists, please update the version number in manifest.yaml" + exit 1 + fi + fi + - name: Check Plugin Deps run: | if [ -f ${{ env.PLUGIN_PATH }}/requirements.txt ]; then diff --git a/.github/workflows/upload-merged-plugin.yaml b/.github/workflows/upload-merged-plugin.yaml index a92caad..57b18fa 100644 --- a/.github/workflows/upload-merged-plugin.yaml +++ b/.github/workflows/upload-merged-plugin.yaml @@ -65,4 +65,4 @@ jobs: - name: Upload Plugin run: | - python3 .scripts/uploader/upload-package.py -p ${{ env.PLUGIN_PATH }} -t ${{ secrets.MARKETPLACE_TOKEN }} --plugin-daemon-path .scripts/dify-plugin-linux-amd64 -u ${{ secrets.MARKETPLACE_BASE_URL }} -f + python3 .scripts/uploader/upload-package.py -p ${{ env.PLUGIN_PATH }} -t ${{ secrets.MARKETPLACE_TOKEN }} --plugin-daemon-path .scripts/dify-plugin-linux-amd64 -u ${{ secrets.MARKETPLACE_BASE_URL }}