diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 553bc1f..6d0a73a 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -44,3 +44,17 @@ jobs: "${changed_files[@]}" \ --message "Update to tideways-php $(awk '$1 == "version"{gsub(/"/,"",$2); print $2}' ${changed_files[1]})" fi + + if ! git diff --quiet Formula/tideways-daemon.rb; then + ghcommit -r ${{ github.repository }} \ + -b master \ + --add Formula/tideways-daemon.rb \ + --message "Update to tideways-daemon $(awk '$1 == "version"{gsub(/"/,"",$2); print $2}' Formula/tideways-daemon.rb)" + fi + + if ! git diff --quiet Formula/tideways-cli.rb; then + ghcommit -r ${{ github.repository }} \ + -b master \ + --add Formula/tideways-cli.rb \ + --message "Update to tideways-cli $(awk '$1 == "version"{gsub(/"/,"",$2); print $2}' Formula/tideways-cli.rb)" + fi diff --git a/Formula/tideways-cli.rb b/Formula/tideways-cli.rb index 4096180..a0a8858 100644 --- a/Formula/tideways-cli.rb +++ b/Formula/tideways-cli.rb @@ -2,15 +2,15 @@ class TidewaysCli < Formula homepage 'https://tideways.com' - version '1.1.0' + version "1.1.0" + checksum = { + "arm64" => "bc4e2346129bde1b5c5ba4a30fbfb6b1ac8ab9e9af9236bf0eecc277139ad312", + "amd64" => "a09bc9f06717101892b120fe92dedf27702be5189a98fdce979a1348ca8b68ad", + } - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/cli/#{version}/tideways-cli_macos_arm64-#{version}.tar.gz" - sha256 'bc4e2346129bde1b5c5ba4a30fbfb6b1ac8ab9e9af9236bf0eecc277139ad312' - else - url "https://tideways.s3.amazonaws.com/cli/#{version}/tideways-cli_macos_amd64-#{version}.tar.gz" - sha256 'a09bc9f06717101892b120fe92dedf27702be5189a98fdce979a1348ca8b68ad' - end + arch = Hardware::CPU.arm? ? "arm64" : "amd64" + url "https://tideways.s3.amazonaws.com/cli/#{version}/tideways-cli_macos_#{arch}-#{version}.tar.gz" + sha256 checksum[arch] def install bin.install "tideways" @@ -18,10 +18,10 @@ def install def caveats return <<~EOS - Follow the instructions on Tideways Profiler website - to import your application settings: + Follow the instructions on Tideways Profiler website + to import your application settings: - https://app.tideways.io/user/cli-import-settings + https://app.tideways.io/user/cli-import-settings EOS end end diff --git a/Formula/tideways-daemon.rb b/Formula/tideways-daemon.rb index f4aa40e..c22483f 100644 --- a/Formula/tideways-daemon.rb +++ b/Formula/tideways-daemon.rb @@ -2,25 +2,25 @@ class TidewaysDaemon < Formula homepage 'https://tideways.com' - version '1.9.2' - - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/daemon/#{version}/tideways-daemon_macos_arm64-#{version}.tar.gz" - sha256 '434f1f1b46c038b810b727d850dfadfe2136d0e00ed1a4200e34d847fbb3c78b' - else - url "https://tideways.s3.amazonaws.com/daemon/#{version}/tideways-daemon_macos_amd64-#{version}.tar.gz" - sha256 '7b04577b15891881860553e7097be6280db705cf52d7931f1e9869c9ad7cf6ba' - end + version "1.9.2" + checksum = { + "arm64" => "434f1f1b46c038b810b727d850dfadfe2136d0e00ed1a4200e34d847fbb3c78b", + "amd64" => "7b04577b15891881860553e7097be6280db705cf52d7931f1e9869c9ad7cf6ba", + } + + arch = Hardware::CPU.arm? ? "arm64" : "amd64" + url "https://tideways.s3.amazonaws.com/daemon/#{version}/tideways-daemon_macos_#{arch}-#{version}.tar.gz" + sha256 checksum[arch] def install - bin.install 'tideways-daemon' + bin.install 'tideways-daemon' - log_dir = var+'log/tideways' - log_dir.mkpath unless log_dir.exist? + log_dir = var+'log/tideways' + log_dir.mkpath unless log_dir.exist? end service do - run [opt_bin/"tideways-daemon", "--address", "127.0.0.1:9135", "--log", HOMEBREW_PREFIX/"var/log/tideways/daemon.log", "--env", "development"] + run [opt_bin/"tideways-daemon", "--address", "127.0.0.1:9135", "--log", HOMEBREW_PREFIX/"var/log/tideways/daemon.log", "--env", "development"] end def caveats @@ -31,4 +31,3 @@ def caveats EOS end end - diff --git a/Formula/tideways-php@8.0.rb b/Formula/tideways-php@8.0.rb index 6aeff0e..012682e 100644 --- a/Formula/tideways-php@8.0.rb +++ b/Formula/tideways-php@8.0.rb @@ -4,19 +4,19 @@ require File.expand_path("../Abstract/abstract-tideways-php-extension", __dir__) class TidewaysPhpAT80 < AbstractTidewaysPhpExtension - init - version "5.10.2" + init + version "5.10.2" + checksum = { + "arm" => "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a", + "x86" => "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a", + } - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-arm.tar.gz" - sha256 "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a" - else - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-x86.tar.gz" - sha256 "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a" - end + arch = Hardware::CPU.arm? ? "arm" : "x86" + url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-#{arch}.tar.gz" + sha256 checksum[arch] - def install - prefix.install "tideways-php-#{php_version}.so" - write_config_file - end + def install + prefix.install "tideways-php-#{php_version}.so" + write_config_file + end end diff --git a/Formula/tideways-php@8.1.rb b/Formula/tideways-php@8.1.rb index d9c9d2d..3f95cb3 100644 --- a/Formula/tideways-php@8.1.rb +++ b/Formula/tideways-php@8.1.rb @@ -4,19 +4,19 @@ require File.expand_path("../Abstract/abstract-tideways-php-extension", __dir__) class TidewaysPhpAT81 < AbstractTidewaysPhpExtension - init - version "5.10.2" + init + version "5.10.2" + checksum = { + "arm" => "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a", + "x86" => "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a", + } - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-arm.tar.gz" - sha256 "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a" - else - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-x86.tar.gz" - sha256 "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a" - end + arch = Hardware::CPU.arm? ? "arm" : "x86" + url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-#{arch}.tar.gz" + sha256 checksum[arch] - def install - prefix.install "tideways-php-#{php_version}.so" - write_config_file - end + def install + prefix.install "tideways-php-#{php_version}.so" + write_config_file + end end diff --git a/Formula/tideways-php@8.2.rb b/Formula/tideways-php@8.2.rb index a3cbd7b..a6912f9 100644 --- a/Formula/tideways-php@8.2.rb +++ b/Formula/tideways-php@8.2.rb @@ -4,19 +4,19 @@ require File.expand_path("../Abstract/abstract-tideways-php-extension", __dir__) class TidewaysPhpAT82 < AbstractTidewaysPhpExtension - init - version "5.10.2" + init + version "5.10.2" + checksum = { + "arm" => "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a", + "x86" => "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a", + } - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-arm.tar.gz" - sha256 "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a" - else - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-x86.tar.gz" - sha256 "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a" - end + arch = Hardware::CPU.arm? ? "arm" : "x86" + url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-#{arch}.tar.gz" + sha256 checksum[arch] - def install - prefix.install "tideways-php-#{php_version}.so" - write_config_file - end + def install + prefix.install "tideways-php-#{php_version}.so" + write_config_file + end end diff --git a/Formula/tideways-php@8.3.rb b/Formula/tideways-php@8.3.rb index 1c02dfd..3d6187b 100644 --- a/Formula/tideways-php@8.3.rb +++ b/Formula/tideways-php@8.3.rb @@ -4,19 +4,19 @@ require File.expand_path("../Abstract/abstract-tideways-php-extension", __dir__) class TidewaysPhpAT83 < AbstractTidewaysPhpExtension - init - version "5.10.2" + init + version "5.10.2" + checksum = { + "arm" => "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a", + "x86" => "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a", + } - if Hardware::CPU.arm? - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-arm.tar.gz" - sha256 "03f48d53e7b5ffd4ce4fe1a862c1a0fda784394fa4a871e1cc29a722f1811e2a" - else - url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-x86.tar.gz" - sha256 "957adea7387c6ec906f9e15a3ce0e12b7ace028dd4fa4be3e69a173f7a355c8a" - end + arch = Hardware::CPU.arm? ? "arm" : "x86" + url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-#{arch}.tar.gz" + sha256 checksum[arch] - def install - prefix.install "tideways-php-#{php_version}.so" - write_config_file - end + def install + prefix.install "tideways-php-#{php_version}.so" + write_config_file + end end diff --git a/scripts/update_formula.php b/scripts/update_formula.php index 35fac4b..9c1df3d 100644 --- a/scripts/update_formula.php +++ b/scripts/update_formula.php @@ -1,54 +1,134 @@ "{$hashArm}", + "x86" => "{$hashX86}", + } -foreach ($architectures as $architecture) { - $archive = file_get_contents('https://tideways.s3.amazonaws.com/extension/' . $extensionVersion . '/tideways-php-' . $extensionVersion . '-macos-' . $architecture . '.tar.gz'); + arch = Hardware::CPU.arm? ? "arm" : "x86" + url "https://tideways.s3.amazonaws.com/extension/#{version}/tideways-php-#{version}-macos-#{arch}.tar.gz" + sha256 checksum[arch] - if ($archive === false) { - throw new RuntimeException("Could not download MacOS archive for Tideways extension version " . $extensionVersion); - } + def install + prefix.install "tideways-php-#{php_version}.so" + write_config_file + end + end - $hashes[$architecture] = hash('sha256', $archive); + FORMULA, + ); } +echo "tideways-daemon", PHP_EOL; +$daemonVersion = $currentVersions['daemon']['version'] ?? throw new RuntimeException("Current Tideways extension version not found in current versions payload."); +$hashArm64 = hash_file('sha256', "https://tideways.s3.amazonaws.com/daemon/{$daemonVersion}/tideways-daemon_macos_arm64-{$daemonVersion}.tar.gz") ?: throw new RuntimeException("Failed to determine ARM64 hash."); +$hashAmd64 = hash_file('sha256', "https://tideways.s3.amazonaws.com/daemon/{$daemonVersion}/tideways-daemon_macos_amd64-{$daemonVersion}.tar.gz") ?: throw new RuntimeException("Failed to determine AMD64 hash."); -foreach ($phpVersions as $phpVersion) { - file_put_contents(__DIR__ . '/../Formula/tideways-php@' . $phpVersion . '.rb', - str_replace( - ['{PHP}', '{VERSION}', '{HASH_ARM}', '{HASH_X86}'], - [str_replace('.', '', $phpVersion), $extensionVersion, $hashes['arm'], $hashes['x86']], - $formulaTemplate - )); -} +file_put_contents( + __DIR__ . '/../Formula/tideways-daemon.rb', + << "{$hashArm64}", + "amd64" => "{$hashAmd64}", + } + + arch = Hardware::CPU.arm? ? "arm64" : "amd64" + url "https://tideways.s3.amazonaws.com/daemon/#{version}/tideways-daemon_macos_#{arch}-#{version}.tar.gz" + sha256 checksum[arch] + + def install + bin.install 'tideways-daemon' + + log_dir = var+'log/tideways' + log_dir.mkpath unless log_dir.exist? + end + + service do + run [opt_bin/"tideways-daemon", "--address", "127.0.0.1:9135", "--log", HOMEBREW_PREFIX/"var/log/tideways/daemon.log", "--env", "development"] + end + + def caveats + <<~EOS + + Please contact support@tideways.com if you have problems setting up the daemon. + + EOS + end + end + + FORMULA, +); + + +echo "tideways-cli", PHP_EOL; +$cliVersion = $currentVersions['cli']['version'] ?? throw new RuntimeException("Current Tideways extension version not found in current versions payload."); +$hashArm64 = hash_file('sha256', "https://tideways.s3.amazonaws.com/cli/{$cliVersion}/tideways-cli_macos_arm64-{$cliVersion}.tar.gz") ?: throw new RuntimeException("Failed to determine ARM64 hash."); +$hashAmd64 = hash_file('sha256', "https://tideways.s3.amazonaws.com/cli/{$cliVersion}/tideways-cli_macos_amd64-{$cliVersion}.tar.gz") ?: throw new RuntimeException("Failed to determine AMD64 hash."); + +file_put_contents( + __DIR__ . '/../Formula/tideways-cli.rb', + << "{$hashArm64}", + "amd64" => "{$hashAmd64}", + } + + arch = Hardware::CPU.arm? ? "arm64" : "amd64" + url "https://tideways.s3.amazonaws.com/cli/#{version}/tideways-cli_macos_#{arch}-#{version}.tar.gz" + sha256 checksum[arch] + + def install + bin.install "tideways" + end + + def caveats + return <<~EOS + Follow the instructions on Tideways Profiler website + to import your application settings: + + https://app.tideways.io/user/cli-import-settings + EOS + end + end + + FORMULA, +);