Publish Plugins Automatically

Background

Updating plugins that others are actively using can be tedious. Traditionally, you would need to modify code, bump versions, push changes, create branches, package files, and submit PRs manually - a repetitive process that slows down development.

Thus, we have created Plugin Auto-PR, a GitHub Actions workflow that automates the entire process. Now you can package, push, and create PRs with a single action, focusing on building great plugins.

Concepts

GitHub Actions

GitHub Actions automates your development tasks in GitHub.

How it works: When triggered (e.g., by a code push), it runs your workflow in a cloud-based virtual machine, handling everything from build to deployment automatically.

Workflow

Limits:

  • Public repositories: Unlimited

  • Private repositories: 2000 minutes per month

Plugin Auto-PR

How it works:

  1. Workflow triggers when you push code to the main branch of your plugin source repository

  2. Workflow reads plugin information from the manifest.yaml file

  3. Automatically packages the plugin as a .difypkg file

  4. Pushes the packaged file to your forked dify-plugins repository

  5. Creates a new branch and commits changes

  6. Automatically creates a PR to merge into the upstream repository

Prerequisites

Repository

  • You already have your own plugin source code repository (e.g., your-name/plugin-source)

  • You already have your own forked plugin repository (e.g., your-name/dify-plugins)

  • Your forked repository already has the plugin directory structure:

Permission

This workflow requires appropriate permissions to function:

  • You need to create a GitHub Personal Access Token (PAT) with sufficient permissions

  • The PAT must have permission to push code to your forked repository

  • The PAT must have permission to create PRs to the upstream repository

Parameters and Configuration

Setup Requirements

To get started with auto-publishing, you will need two key components:

manifest.yaml file: This file drives the automation process:

  • name: Your plugin’s name (affects package and branch names)

  • version: Semantic version number (increment with each release)

  • author: Your GitHub username (determines repository paths)

PLUGIN_ACTION Secret: You need to add this secret to your plugin source repository:

  • Value: Must be a Personal Access Token (PAT) with sufficient permissions

  • Permission: Ability to push branches to your forked repository and create PRs to the upstream repository

Automatically-Generated Parameters

Once set up, the workflow automatically handles these parameters:

  • GitHub username: Read from the author field in manifest.yaml

  • Author folder name: Consistent with the author field

  • Plugin name: Read from the name field in manifest.yaml

  • Branch name: bump-{plugin-name}-plugin-{version}

  • Package filename: {plugin-name}-{version}.difypkg

  • PR title and content: Automatically generated based on plugin name and version

Step-by-Step Guide

1

Prepare Repositories

Ensure you have forked the official dify-plugins repository and have your own plugin source repository.

2

Configure Secret

Navigate to your plugin source repository, click Settings > Secrets and variables > Actions > New repository secret, and create a GitHub Secret:

  • Name: PLUGIN_ACTION

  • Value: GitHub Personal Access Token (PAT) with write permissions to the target repository (your-name/dify-plugins)

Create Secrets
3

Create Workflow File

Create a .github/workflows/ directory in your repository, create a file named plugin-publish.yml in this directory, and copy the following content into the file:

4

Update manifest.yaml

Ensure those following fields are correctly set:

Usage Guide

First-time Setup

When setting up the auto-publish workflow for the first time, complete these steps:

  1. Ensure you have forked the official dify-plugins repository

  2. Ensure your plugin source repository structure is correct

  3. Set up the PLUGIN_ACTION Secret in your plugin source repository

  4. Create the workflow file .github/workflows/plugin-publish.yml

  5. Ensure the name and author fields in the manifest.yaml file are correctly configured

Subsequent Update

To publish new versions after setup:

  1. Modify the code

  2. Update the version field in manifest.yaml

Release
  1. Push all changes to the main branch

  2. Wait for GitHub Actions to complete packaging, branch creation, and PR submission

Outcome

When you push code to the main branch of your plugin source repository, GitHub Actions will automatically execute the publishing process:

  • Package the plugin in {plugin-name}-{version}.difypkg format

  • Push the packaged file to the target repository

  • Create a PR to merge into the fork repository

Outcome

Example Repository

See example repository to understand configuration and best practices.

Last updated