dify.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. class Dify < Formula
  2. desc "Dify"
  3. homepage "https://github.com/langgenius/dify-plugin-daemon"
  4. VERSION = "0.0.1"
  5. version VERSION
  6. if OS.mac?
  7. if Hardware::CPU.intel?
  8. url "https://github.com/langgenius/dify-plugin-daemon/releases/download/#{VERSION}/dify-plugin-darwin-amd64"
  9. elsif Hardware::CPU.arm?
  10. url "https://github.com/langgenius/dify-plugin-daemon/releases/download/#{VERSION}/dify-plugin-darwin-arm64"
  11. end
  12. elsif OS.linux?
  13. if Hardware::CPU.intel?
  14. url "https://github.com/langgenius/dify-plugin-daemon/releases/download/#{VERSION}/dify-plugin-linux-amd64"
  15. elsif Hardware::CPU.arm?
  16. url "https://github.com/langgenius/dify-plugin-daemon/releases/download/#{VERSION}/dify-plugin-linux-arm64"
  17. end
  18. elsif OS.windows?
  19. url "https://github.com/langgenius/dify-plugin-daemon/releases/download/#{VERSION}/dify-plugin-windows-amd64"
  20. end
  21. def install
  22. # Determine the OS and architecture to select the correct binary.
  23. os = if OS.mac?
  24. "darwin"
  25. elsif OS.linux?
  26. "linux"
  27. elsif OS.windows?
  28. "windows"
  29. end
  30. arch = if Hardware::CPU.intel?
  31. "amd64"
  32. elsif Hardware::CPU.arm?
  33. "arm64"
  34. end
  35. bin.install "dify-plugin-#{os}-#{arch}" => "dify"
  36. end
  37. test do
  38. # Verify that running `dify --version` returns the expected version.
  39. assert_match VERSION.to_s, shell_output("#{bin}/dify --version")
  40. end
  41. end