refactor: add makefile and refactor the github action#678
refactor: add makefile and refactor the github action#678
Conversation
There was a problem hiding this comment.
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.
| # 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" |
There was a problem hiding this comment.
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.
| -o "$$stage_dir/$$binary_name" $(CLI_TARGET); \ | ||
| cp LICENSE "$$stage_dir/LICENSE" | ||
|
|
||
| archive-cli: |
| tar -C "$$stage_root" -czf "$$asset_path" "$$package_name"; \ | ||
| fi | ||
|
|
||
| package-cli: build-cli archive-cli |
| 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); \ |
There was a problem hiding this comment.
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); \
| go build $(GO_BUILD_FLAGS) -o "$$stage_dir/$$binary_name" $(SLIM_TARGET); \ | ||
| cp LICENSE "$$stage_dir/LICENSE" | ||
|
|
||
| archive-slim: |
| tar -C "$$stage_root" -czf "$$asset_path" "$$package_name"; \ | ||
| fi | ||
|
|
||
| package-slim: build-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 |
There was a problem hiding this comment.
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
Description
Refactor the action and add makefile
Type of Change
Essential Checklist
Testing
Bug Fix (if applicable)
Fixes #123orCloses #123)Additional Information
Please provide any additional context that would help reviewers understand the changes.