-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from langgenius/feat/homebrew
feat: homebrew
- Loading branch information
Showing
5 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ __pycache__ | |
media-cache | ||
subprocesses | ||
working | ||
cwd/ | ||
cwd/ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
PLATFORMS = darwin linux windows | ||
ARCHS = amd64 arm64 | ||
BIN_DIR = bin | ||
CMD_DIR = ./cmd/commandline | ||
|
||
.PHONY: build | ||
build: | ||
@mkdir -p $(BIN_DIR) | ||
@for platform in $(PLATFORMS); do \ | ||
for arch in $(ARCHS); do \ | ||
if [ "$$platform" = "windows" ]; then \ | ||
ext=".exe"; \ | ||
else \ | ||
ext=""; \ | ||
fi; \ | ||
bin_name=dify-plugin-$$platform-$$arch$$ext; \ | ||
echo "Building $$bin_name"; \ | ||
GOOS=$$platform GOARCH=$$arch go build -o $(BIN_DIR)/$$bin_name $(CMD_DIR); \ | ||
if [ "$$platform" != "windows" ]; then chmod +x $(BIN_DIR)/$$bin_name; fi; \ | ||
done; \ | ||
done | ||
|
||
.PHONY: tarball | ||
tarball: build | ||
@for platform in $(PLATFORMS); do \ | ||
for arch in $(ARCHS); do \ | ||
if [ "$$platform" = "windows" ]; then \ | ||
ext=".exe"; \ | ||
archive=$(BIN_DIR)/dify-plugin-$$platform-$$arch.zip; \ | ||
echo "Creating $$archive"; \ | ||
zip -j $$archive $(BIN_DIR)/dify-plugin-$$platform-$$arch$$ext; \ | ||
else \ | ||
ext=""; \ | ||
archive=$(BIN_DIR)/dify-plugin-$$platform-$$arch.tar.gz; \ | ||
echo "Creating $$archive"; \ | ||
tar -czvf $$archive -C $(BIN_DIR) dify-plugin-$$platform-$$arch$$ext; \ | ||
fi; \ | ||
done; \ | ||
done | ||
|
||
.PHONY: sha256 | ||
sha256: tarball | ||
@for platform in $(PLATFORMS); do \ | ||
for arch in $(ARCHS); do \ | ||
if [ "$$platform" = "windows" ]; then \ | ||
archive=$(BIN_DIR)/dify-plugin-$$platform-$$arch.zip; \ | ||
else \ | ||
archive=$(BIN_DIR)/dify-plugin-$$platform-$$arch.tar.gz; \ | ||
fi; \ | ||
hash_file=$(BIN_DIR)/sha256_$$platform\_$$arch; \ | ||
echo "Computing SHA256 for $$archive"; \ | ||
shasum -a 256 $$archive | awk '{ print $$1 }' > $$hash_file; \ | ||
done; \ | ||
done | ||
|
||
.PHONY: update_formula | ||
update_formula: sha256 | ||
@cp dify.rb dify.rb.bak | ||
@for platform in $(PLATFORMS); do \ | ||
for arch in $(ARCHS); do \ | ||
placeholder="SHA256_$$(echo $$platform | tr a-z A-Z)_$$(echo $$arch | tr a-z A-Z)"; \ | ||
hash=$$(cat $(BIN_DIR)/sha256_$$platform\_$$arch); \ | ||
echo "Updating formula for $$placeholder"; \ | ||
sed -i '' "s/sha256 \"$$placeholder\"/sha256 \"$$hash\"/" dify.rb; \ | ||
done; \ | ||
done | ||
@rm -f dify.rb.bak | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(BIN_DIR)/* | ||
|
||
.PHONY: all | ||
all: update_formula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Dify Plugin Daemon | ||
|
||
## Description | ||
|
||
## Installation | ||
|
||
```bash | ||
brew install --build-from-source ./dify.rb | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Dify < Formula | ||
desc "Dify Plugin Command Line Tool" | ||
homepage "https://github.com/langgenius/dify-plugin-daemon" | ||
version "0.1.0" | ||
license "MIT" | ||
|
||
if OS.mac? && Hardware::CPU.intel? | ||
url "file://#{__dir__}/bin/dify-plugin-darwin-amd64.tar.gz" | ||
sha256 "3b0172bfdaf19396a855974b6f83e03a86ce2a073615cd7d6fbbb104c3d96946" | ||
elsif OS.mac? && Hardware::CPU.arm? | ||
url "file://#{__dir__}/bin/dify-plugin-darwin-arm64.tar.gz" | ||
sha256 "8a527f7bc61046aa11992d76cc2e3fe2a2c38cf3434d882273fcba30dd3a2e00" | ||
end | ||
|
||
def install | ||
if Hardware::CPU.intel? | ||
bin.install "dify-plugin-darwin-amd64" => "dify" | ||
else | ||
bin.install "dify-plugin-darwin-arm64" => "dify" | ||
end | ||
end | ||
|
||
test do | ||
system "#{bin}/dify", "--version" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Build homebrew | ||
|
||
## Intallation | ||
|
||
### Install homebrew | ||
|
||
```bash | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
|
||
brew -v | ||
``` | ||
|
||
### Build CLI tool | ||
|
||
```bash | ||
# Build the CLI tool from source | ||
make build | ||
# Generate the sha256 checksum | ||
make sha256 | ||
# Update the formula with the new sha256 checksum | ||
make update_formula | ||
# Clean the build | ||
make clean | ||
# Execute all the above commands | ||
make all | ||
``` | ||
|
||
### Install CLI tool | ||
|
||
```bash | ||
brew install --build-from-source ./dify.rb | ||
``` |