diff --git a/.github/workflows/homebrew-install.yml b/.github/workflows/homebrew-install.yml deleted file mode 100644 index 4b23e97..0000000 --- a/.github/workflows/homebrew-install.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Homebrew Install - -on: - workflow_dispatch: - pull_request: - branches: - - main - -concurrency: - group: homebrew-install-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - name: Homebrew Install - defaults: - run: - shell: bash - strategy: - matrix: - runner-image: - - ubuntu-latest # linux-amd64 - - ubuntu-24.04-arm # linux-arm64 - - macos-latest # darwin-arm64 - - macos-13 # darwin-amd64 - runs-on: ${{ matrix.runner-image }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Homebrew - shell: bash - if: ${{ matrix.runner-image == 'ubuntu-24.04-arm'}} - run: | - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - - - name: Set up Homebrew - id: set-up-homebrew - uses: Homebrew/actions/setup-homebrew@main - - - name: Homebrew Install Dify - run: brew install ./dify.rb - - - name: Homebrew Test Dify - run: brew test dify diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..cbb4554 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,54 @@ +name: brew test-bot + +on: + push: + branches: + - main + pull_request: + +concurrency: + group: homebrew-tests-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test-bot: + strategy: + matrix: + os: [ ubuntu-22.04, macos-15-intel, macos-26 ] + runs-on: ${{ matrix.os }} + permissions: + actions: read + checks: read + contents: read + pull-requests: read + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache Homebrew Bundler RubyGems + uses: actions/cache@v4 + with: + path: ${{ steps.set-up-homebrew.outputs.gems-path }} + key: ${{ matrix.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ matrix.os }}-rubygems- + + - run: brew test-bot --only-cleanup-before + + - run: brew test-bot --only-setup + + - run: brew test-bot --only-tap-syntax + + - run: brew test-bot --only-formulae + if: github.event_name == 'pull_request' + + - run: brew test dify + +# - name: Upload bottles as artifact +# if: always() && github.event_name == 'pull_request' +# uses: actions/upload-artifact@v4 +# with: +# name: bottles_${{ matrix.os }} +# path: '*.bottle.*' diff --git a/dify.rb b/dify.rb index 72043c2..cc96540 100644 --- a/dify.rb +++ b/dify.rb @@ -1,24 +1,28 @@ +# typed: strict +# frozen_string_literal: true + +# Dify class Dify < Formula - desc "Dify is a cli tool to help you develop your Dify projects." + desc "CLI tool for Dify plugin development" homepage "https://github.com/langgenius/dify-plugin-daemon" - license "MIT" - version "0.3.1" - livecheck do - url :stable - strategy :github_latest + os_name=if OS.mac? + "darwin" + elsif OS.linux? + "linux" + else + "unknown" end - os_name = OS.mac? ? "darwin" : (OS.linux? ? "linux" : "unknown") - arch_name = Hardware::CPU.arm? ? "arm64" : (Hardware::CPU.intel? ? "amd64" : "unknown") - CLI_BIN_NAME = "dify-plugin-#{os_name}-#{arch_name}" + arch_name=if Hardware::CPU.arm? + "arm64" + elsif Hardware::CPU.intel? + "amd64" + else + "unknown" + end - CHECKSUM_MAP = { - "dify-plugin-darwin-amd64" => "1b0636f9e106ab71e15c5276d931020b9bd427211fd91c8b7dca22ca243802b8", - "dify-plugin-darwin-arm64" => "5fece620cb415607b88e1e7628e3c412d6db605a85d50820d1a889631cb7f40e", - "dify-plugin-linux-amd64" => "d5537d49cab12a61e510071e25efa26aefe969fbcc788e8760eca436b9daeee1", - "dify-plugin-linux-arm64" => "e82dde9fc1068c8c20478744fb0190f11d9fc5f68d8248e5d84fb36a238bcaf7", - } + CLI_BIN_NAME = "dify-plugin-#{os_name}-#{arch_name}".freeze def self.get_sha256(cli_name) CHECKSUM_MAP.fetch(cli_name) do |key| @@ -26,15 +30,29 @@ def self.get_sha256(cli_name) end end - # Define the URL and the SHA256 checksum for binary file - url "#{homepage}/releases/download/#{version}/#{CLI_BIN_NAME}" + CHECKSUM_MAP = { + "dify-plugin-darwin-amd64" => "55ec70958cb313e9026c8969f35c5de4c50e044102816f84450de5edeae70d0a", + "dify-plugin-darwin-arm64" => "95dd55c2e949eaf716a5574121f6d86c80afbf1abbc552e8d4ddceb5a0f8028b", + "dify-plugin-linux-amd64" => "f26e5e5faae3d3931979798932aa6542c71de827b470132f385a95e0d74c5dcf", + "dify-plugin-linux-arm64" => "078149cf70cd3f1fdee11b733c1f1e49e594628f69c22a60a1ca0abeabe3569d", + }.freeze + + url "#{homepage}/releases/download/0.3.2/#{CLI_BIN_NAME}" + version "0.3.2" sha256 get_sha256(CLI_BIN_NAME) + livecheck do + url :stable + strategy :github_latest + end + + # Define the URL and the SHA256 checksum for binary file + def install # move the binary file to bin directory - bin.install "#{CLI_BIN_NAME}" => "dify" - system "chmod +x #{bin}/dify" - system "#{bin}/dify version" + bin.install CLI_BIN_NAME.to_s => "dify" + chmod("+x", "#{bin}/dify") + system "#{bin}/dify", "version" end test do