Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 276 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
name: Release

# Builds the Dify plugin package (diffbot-<version>.difypkg) and publishes it on a
# GitHub Release, which is what Dify's "Install plugin from GitHub" reads.
#
# Contract:
# - Pushing a tag vX.Y.Z (or vX.Y.Z-rc.N) runs verify -> gates -> package ->
# github-release. The tag must equal `version` in diffbot/manifest.yaml, which must
# equal `[project] version` in diffbot/pyproject.toml, and CHANGELOG.md must have a
# "## [X.Y.Z]" section. The release notes are that section. A version containing "-"
# is a prerelease: it may reuse the base "## [X.Y.Z]" section and its GitHub Release
# is marked Pre-release.
# - workflow_dispatch is a dry run: verify, gates and package run and the .difypkg is
# uploaded as a workflow artifact. A dispatch never creates or edits a GitHub
# Release, even on a tag ref.
# - Official .difypkg files come only from this workflow. Nobody commits one (dist/ is
# gitignored) or attaches a hand-built one to a release.
# - This workflow does NOT submit to the Dify Marketplace (that is the manual
# SUBMISSION.md runbook) and does NOT sign the package (Dify signs marketplace
# builds after review). No secrets are used; tests are offline (httpx.MockTransport).
#
# Shared ideas (CHANGELOG-driven notes, --prerelease for "-" versions, dispatch dry
# run) follow the diffbot npm release standard; see diffbot-dev-docs
# docs/conventions/dify-plugin-release.md for this repo's standard.
on:
push:
tags: ["v*"]
workflow_dispatch:

permissions:
contents: read

# A release run is never cancelled halfway; re-runs for the same ref queue.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
verify:
name: Verify version
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

# manifest.yaml is the source of truth; pyproject.toml and the tag must agree.
# Only the top-level (unindented) `version:` is read: meta.version is the manifest
# schema version and meta.runner.version is Python, neither is the plugin version.
- name: Check tag matches plugin version
id: version
run: |
set -euo pipefail
manifest=$(sed -n 's/^version:[[:space:]]*//p' diffbot/manifest.yaml | tr -d "\"' \r")
if [ -z "$manifest" ] || [ "$(printf '%s\n' "$manifest" | wc -l)" -ne 1 ]; then
echo "::error::Could not read a single top-level version from diffbot/manifest.yaml."
exit 1
fi
if ! printf '%s' "$manifest" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "::error::diffbot/manifest.yaml version '${manifest}' is not like 1.2.3 or 1.2.3-rc.0."
exit 1
fi
pyproject=$(python3 -c 'import tomllib; print(tomllib.load(open("diffbot/pyproject.toml", "rb"))["project"]["version"])')
if [ "$manifest" != "$pyproject" ]; then
echo "::error::diffbot/manifest.yaml version ${manifest} does not match diffbot/pyproject.toml version ${pyproject}."
exit 1
fi
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
tag=${GITHUB_REF_NAME#v}
if [ "$manifest" != "$tag" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match plugin version ${manifest}. Bump diffbot/manifest.yaml and diffbot/pyproject.toml, then re-tag."
exit 1
fi
fi
echo "version=${manifest}" >> "$GITHUB_OUTPUT"
echo "Versions agree: ${manifest}"

# Checked before the gates so a tag without release notes fails within seconds.
# Headings are Keep a Changelog style, matched at the start of the line, so a
# non-version heading such as "## Earlier, ..." never counts.
- name: Check CHANGELOG.md has a section for this version
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
has_section() {
awk -v hdr="## [$1]" 'index($0, hdr) == 1 { found = 1 } END { exit !found }' CHANGELOG.md
}
# A prerelease (0.2.1-rc.0) may reuse its base version's section (0.2.1).
if has_section "${VERSION}"; then
hdr_version="${VERSION}"
elif [ "${VERSION%%-*}" != "${VERSION}" ] && has_section "${VERSION%%-*}"; then
hdr_version="${VERSION%%-*}"
echo "Prerelease ${VERSION}: using the '## [${hdr_version}]' section."
else
echo "::error::CHANGELOG.md has no '## [${VERSION}]' section."
exit 1
fi
body=$(awk -v hdr="## [${hdr_version}]" '
index($0, hdr) == 1 { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md)
if ! printf '%s' "$body" | grep -q '[^[:space:]]'; then
echo "::error::CHANGELOG.md section '## [${hdr_version}]' is empty."
exit 1
fi
echo "Found '## [${hdr_version}]'."

# Same commands as test.yml. Offline only: no live tests, no secrets.
gates:
name: Gates (pytest)
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: diffbot/requirements.txt
- run: pip install -r diffbot/requirements.txt pytest
- run: pytest -q

package:
name: Package .difypkg
needs: [verify, gates]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
# Pinned dify CLI from https://github.com/langgenius/dify-plugin-daemon/releases.
# The release publishes no checksum file; the SHA256 is the asset digest GitHub
# reports for dify-plugin-linux-amd64. To bump (see the dev-docs standard):
# gh release view <tag> --repo langgenius/dify-plugin-daemon \
# --json assets --jq '.assets[] | select(.name=="dify-plugin-linux-amd64") | .digest'
# then update both values here in one PR and dispatch a dry run.
DIFY_CLI_VERSION: "0.6.15"
DIFY_CLI_SHA256: "d0a1e3b25bd6c5f6cd749cad2cf04817ea808344e6cc07a2c49bb0108019ab93"
VERSION: ${{ needs.verify.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install pinned dify CLI
run: |
set -euo pipefail
bin="${RUNNER_TEMP}/bin"
mkdir -p "$bin"
curl -fsSL --retry 3 -o "${bin}/dify" \
"https://github.com/langgenius/dify-plugin-daemon/releases/download/${DIFY_CLI_VERSION}/dify-plugin-linux-amd64"
echo "${DIFY_CLI_SHA256} ${bin}/dify" | sha256sum -c -
chmod +x "${bin}/dify"
echo "$bin" >> "$GITHUB_PATH"
"${bin}/dify" version

- name: Build package
run: |
set -euo pipefail
dify plugin package ./diffbot -o "diffbot-${VERSION}.difypkg"

# Sanity checks: the file exists, has a plausible size (the 0.1.0 package was
# about 49 KB), contains the manifest, and contains nothing that .difyignore
# should have kept out.
- name: Check package
run: |
set -euo pipefail
pkg="diffbot-${VERSION}.difypkg"
size=$(stat -c %s "$pkg")
if [ "$size" -lt 10240 ] || [ "$size" -gt 10485760 ]; then
echo "::error::${pkg} is ${size} bytes; expected between 10 KiB and 10 MiB."
exit 1
fi
files=$(unzip -Z1 "$pkg")
if ! printf '%s\n' "$files" | grep -qx 'manifest.yaml'; then
echo "::error::${pkg} has no top-level manifest.yaml."
exit 1
fi
if printf '%s\n' "$files" | grep -E '(^|/)(\.env|\.git/.*|\.venv/.*|__pycache__/.*|[^/]*\.pem)$'; then
echo "::error::${pkg} contains files that must not ship (listed above)."
exit 1
fi
sha=$(sha256sum "$pkg" | cut -d' ' -f1)
# The CLI logs "plugin checksum checksum=<hex>" on stderr.
dify_checksum=$(dify plugin checksum "$pkg" 2>&1 | sed -n 's/.*checksum=\([0-9a-f]\{64\}\).*/\1/p')
if [ -z "$dify_checksum" ]; then
echo "::error::Could not read a checksum from 'dify plugin checksum'."
exit 1
fi
{
echo "### ${pkg}"
echo ""
echo "- Size: ${size} bytes, $(printf '%s\n' "$files" | wc -l) files"
echo "- SHA256: \`${sha}\`"
echo "- \`dify plugin checksum\`: \`${dify_checksum}\`"
echo "- dify CLI: ${DIFY_CLI_VERSION}"
} >> "$GITHUB_STEP_SUMMARY"
cat "$GITHUB_STEP_SUMMARY"

- uses: actions/upload-artifact@v4
with:
name: difypkg
path: diffbot-${{ needs.verify.outputs.version }}.difypkg
if-no-files-found: error
retention-days: 30

github-release:
name: Publish GitHub Release
needs: [verify, package]
runs-on: ubuntu-latest
timeout-minutes: 5
# Only for real tag pushes; a workflow_dispatch (even on a tag ref) stops at package.
if: github.event_name == 'push' && github.ref_type == 'tag'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/download-artifact@v4
with:
name: difypkg
path: ${{ runner.temp }}/difypkg

- name: Extract release notes from CHANGELOG.md
env:
VERSION: ${{ needs.verify.outputs.version }}
run: |
set -euo pipefail
# Everything after "## [VERSION]" up to the next "## " heading. A prerelease
# without its own section uses its base version's section.
hdr_version="${VERSION}"
if ! awk -v hdr="## [${VERSION}]" 'index($0, hdr) == 1 { found = 1 } END { exit !found }' CHANGELOG.md; then
hdr_version="${VERSION%%-*}"
fi
awk -v hdr="## [${hdr_version}]" '
index($0, hdr) == 1 { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md > "${RUNNER_TEMP}/notes.md"
if ! grep -q '[^[:space:]]' "${RUNNER_TEMP}/notes.md"; then
echo "::error::CHANGELOG.md section for ${VERSION} is empty."
exit 1
fi
wc -l "${RUNNER_TEMP}/notes.md"

- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.verify.outputs.version }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
repo="${GITHUB_REPOSITORY}"
pkg="${RUNNER_TEMP}/difypkg/diffbot-${VERSION}.difypkg"
test -s "$pkg"
if gh release view "$tag" --repo "$repo" >/dev/null 2>&1; then
echo "Release $tag already exists; leaving its notes as they are and re-uploading the package."
gh release upload "$tag" "$pkg" --repo "$repo" --clobber
exit 0
fi
prerelease=()
case "$VERSION" in *-*) prerelease=(--prerelease) ;; esac
gh release create "$tag" "$pkg" \
--repo "$repo" \
--title "$tag" \
--verify-tag \
--notes-file "${RUNNER_TEMP}/notes.md" \
"${prerelease[@]}"
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 0.2.0 - SDK 3.4.1 parity
## [0.2.0] - SDK 3.4.1 parity

Pins `diffbot==3.4.1` (exact). Not released: no tag, no marketplace submission.

Expand Down Expand Up @@ -28,7 +28,7 @@ Pins `diffbot==3.4.1` (exact). Not released: no tag, no marketplace submission.
- Removed the `client.request()` fallbacks in `diffbot/tools/sdk.py` for `verify_token`, `crawl_download`, and extract options, and the local response TypedDicts in `tools/sdk_types.py`. `diffbot==3.4.0` has all of them natively. No behavior change.
- Reran the marketplace validator on the rebuilt package; results are in SUBMISSION.md.

## 0.1.0 - 2026-11-17
## [0.1.0] - 2026-11-17

Plugin version stays 0.1.0. It is not on the Dify Marketplace.

Expand Down
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,36 @@ The tests serve every request from `httpx.MockTransport` and make no Diffbot cal

GitHub CI (`.github/workflows/test.yml`) installs `diffbot/requirements.txt`, including `diffbot==3.4.1`, and runs the full suite.

## Package
## Release

Install the Dify plugin CLI from [langgenius/dify-plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) and run from the repository root:
The official package is built by CI, not by hand. `.github/workflows/release.yml` runs when a `vX.Y.Z` tag is pushed:

1. `verify`: the tag must equal `version` in `diffbot/manifest.yaml`, which must equal `[project] version` in `diffbot/pyproject.toml`, and `CHANGELOG.md` must have a `## [X.Y.Z]` section.
2. `gates`: the same offline `pytest -q` as `test.yml`.
3. `package`: `dify plugin package ./diffbot -o diffbot-X.Y.Z.difypkg` with a pinned, checksum-verified dify CLI (currently 0.6.15), plus size and content checks. The package is uploaded as the `difypkg` workflow artifact.
4. `github-release`: creates the GitHub Release for the tag with the CHANGELOG section as notes and the `.difypkg` attached. A version containing `-` (for example `0.2.1-rc.0`) is marked Pre-release and may reuse the base `## [0.2.1]` section.

To cut a release, bump `version` in `diffbot/manifest.yaml` and `diffbot/pyproject.toml` and add the `## [X.Y.Z] - YYYY-MM-DD` CHANGELOG section in a PR, merge it, then tag the merge commit and push the tag:

```bash
git fetch origin && git tag vX.Y.Z origin/main && git push origin vX.Y.Z
```

`gh workflow run release.yml --repo diffbot/dify-diffbot --ref <branch>` is a dry run: it runs verify, gates and package and uploads the `difypkg` artifact, and never creates a GitHub Release, even on a tag ref.

Dify's "Install plugin from GitHub" reads these Releases: enter `https://github.com/diffbot/dify-diffbot`, pick the version, and pick `diffbot-X.Y.Z.difypkg`.

The workflow does not sign the package and does not submit it to the Dify Marketplace. Marketplace submission is a separate manual step (SUBMISSION.md). Do not commit a `.difypkg` or attach a hand-built one to a Release.

## Package locally (development)

For local testing, install the Dify plugin CLI from [langgenius/dify-plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) and run from the repository root:

```bash
dify plugin package ./diffbot -o dist/diffbot-0.2.0.difypkg
dify plugin checksum dist/diffbot-0.2.0.difypkg
```

`dist/` is ignored by git. The package is unsigned; Dify signs marketplace builds after review. Self-hosted Dify rejects unsigned local installs unless an administrator trusts a signature or turns off verification. Signing commands are in `diffbot/README.md`. Never commit a private key.
`dist/` is ignored by git. The package is unsigned, whether built locally or by the release workflow; Dify signs marketplace builds after review. Self-hosted Dify rejects unsigned installs (local file or GitHub) unless an administrator trusts a signature or turns off verification. Signing commands are in `diffbot/README.md`. Never commit a private key.

Marketplace validation is `validator/validate-difypkg.py` from [langgenius/dify-marketplace-toolkit](https://github.com/langgenius/dify-marketplace-toolkit). The last result is recorded in SUBMISSION.md.
8 changes: 8 additions & 0 deletions SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ By default the plugin process only talks to these four hosts. Tool parameters ca

## Package the file they will attach

Once the version is tagged, the `.difypkg` to submit is the one `.github/workflows/release.yml` attached to its GitHub Release. Then the marketplace file and the "Install plugin from GitHub" file are the same bytes. Download it and validate that file:

```bash
gh release download v0.2.0 --repo diffbot/dify-diffbot --pattern 'diffbot-0.2.0.difypkg' --dir dist
```

The release workflow does not open the marketplace PR. Everything below is still manual. A local build, for checking before a tag exists:

From a checkout of the plugin, with the Dify plugin CLI (the 18 November 2026 run used `dify` v0.6.15, the same as the v0.1 run):

```bash
Expand Down
4 changes: 4 additions & 0 deletions diffbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ In an Agent, add the Diffbot tools and ask for a company, a news topic, or a URL

Extract accepts `http` and `https` URLs; a bare domain such as `example.com` gets `https://`. Localhost, link-local, and private literal addresses are rejected before the request is sent.

## Install from GitHub

Each tagged version has a GitHub Release at https://github.com/diffbot/dify-diffbot/releases with the `.difypkg` attached, built by the repository's release workflow. In Dify, open Plugins, choose Install plugin from GitHub, enter `https://github.com/diffbot/dify-diffbot`, then pick the version and `diffbot-<version>.difypkg`. The package is unsigned, so the signature notes below apply to this route too.

## Install the package locally

From the repository root, with the [Dify plugin CLI](https://github.com/langgenius/dify-plugin-daemon) installed:
Expand Down
Loading