Skip to content

refactor: add makefile and refactor the github action#678

Open
41tair wants to merge 1 commit intomainfrom
feat/slim-action
Open

refactor: add makefile and refactor the github action#678
41tair wants to merge 1 commit intomainfrom
feat/slim-action

Conversation

@41tair
Copy link
Copy Markdown
Member

@41tair 41tair commented Apr 7, 2026

Description

Refactor the action and add makefile

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Please provide any additional context that would help reviewers understand the changes.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. plugin-daemon labels Apr 7, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the distribution format from raw binaries to compressed .tar.gz archives, updating the installation script, README, and GitHub Action templates accordingly. A new Makefile is introduced to manage cross-platform builds and packaging. Feedback includes ensuring the default version in the install script is compatible with the new archive format, adding missing version flags to the slim build target, and refining Makefile dependencies to prevent race conditions during parallel builds. Additionally, it is recommended to use the latest release URL in the workflow template to avoid hardcoding versions.

Comment thread .script/install.sh
# Define download URL and archive layout
PACKAGE_NAME="dify-plugin-$OS-$ARCH"
ARCHIVE_NAME="$PACKAGE_NAME.tar.gz"
DOWNLOAD_URL="https://github.com/langgenius/dify-plugin-daemon/releases/download/$VERSION/$ARCHIVE_NAME"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The DOWNLOAD_URL relies on the VERSION variable, which defaults to 0.0.1 at the top of this script. Since the .tar.gz archive format is being introduced in this PR, it is unlikely that version 0.0.1 contains these assets. Please ensure the default VERSION is updated to a compatible version (e.g., 0.0.7) to avoid 404 errors for users running the script without explicitly setting the environment variable.

Comment thread Makefile
-o "$$stage_dir/$$binary_name" $(CLI_TARGET); \
cp LICENSE "$$stage_dir/LICENSE"

archive-cli:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The archive-cli target depends on the output of build-cli. Adding an explicit dependency ensures that the build step always runs before archiving, which is especially important for correctness and when running targets individually.

archive-cli: build-cli

Comment thread Makefile
tar -C "$$stage_root" -czf "$$asset_path" "$$package_name"; \
fi

package-cli: build-cli archive-cli
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By making package-cli depend only on archive-cli (which in turn depends on build-cli), you avoid potential race conditions during parallel builds (e.g., make -j) where the archiver might start before the compiler finishes.

package-cli: archive-cli

Comment thread Makefile
rm -rf "$$stage_dir"; \
mkdir -p "$$stage_dir"; \
CGO_ENABLED=0 GOOS="$(GOOS)" GOARCH="$(GOARCH)" \
go build $(GO_BUILD_FLAGS) -o "$$stage_dir/$$binary_name" $(SLIM_TARGET); \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The build-slim target is missing the version injection via -ldflags, which is present in the build-cli target. This ensures that the binary reports the correct version when queried, maintaining consistency across all distributed binaries.

		CGO_ENABLED=0 GOOS="$(GOOS)" GOARCH="$(GOARCH)" \
			go build $(GO_BUILD_FLAGS) -ldflags "-X main.VersionX=$(VERSION)" \
			-o "$$stage_dir/$$binary_name" $(SLIM_TARGET); \

Comment thread Makefile
go build $(GO_BUILD_FLAGS) -o "$$stage_dir/$$binary_name" $(SLIM_TARGET); \
cp LICENSE "$$stage_dir/LICENSE"

archive-slim:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The archive-slim target depends on the output of build-slim. Adding an explicit dependency ensures that the build step always runs before archiving.

archive-slim: build-slim

Comment thread Makefile
tar -C "$$stage_root" -czf "$$asset_path" "$$package_name"; \
fi

package-slim: build-slim archive-slim
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By making package-slim depend only on archive-slim, you ensure a correct execution order during parallel builds.

package-slim: archive-slim


wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64
chmod +x dify-plugin-linux-amd64
wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.7/dify-plugin-linux-amd64.tar.gz
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding version 0.0.7 in a template makes it brittle. Using the GitHub latest release URL ensures that new plugins created from this template will always use the most recent version of the CLI tool without requiring manual updates to the template whenever a new daemon version is released.

          wget https://github.com/langgenius/dify-plugin-daemon/releases/latest/download/dify-plugin-linux-amd64.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin-daemon size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant