diff --git a/cicd/generate_brew_formula.py b/cicd/generate_brew_formula.py new file mode 100644 index 0000000..1da10d5 --- /dev/null +++ b/cicd/generate_brew_formula.py @@ -0,0 +1,98 @@ +import requests +import json + +github_repo = "https://github.com/vedic-lang/vedic" + + +def get_tag_number() -> str: + url = "https://api.github.com/repos/vedic-lang/vedic/releases/latest" + response = requests.get(url) + data = json.loads(response.text) + return data["tag_name"].replace("v", "") + + +tag = get_tag_number() + + +def get_sha_values() -> dict: + url = f"{github_repo}/releases/download/v{tag}/sha256sums.txt" + response = requests.get(url) + sha_values = { + each.split("/")[-1].strip(): each.split(" ")[0].strip() + for each in str(response.text).split("\n") + } + print(url, response, sha_values) + return sha_values + + +sha_values = get_sha_values() + + +# DEFUALT +version = "{version}" +bin = "{bin}" +homepage = "{homepage}" + +tap_code = f"""class vedic < Formula + desc "vedic-lang is a Sanskrit programming language" + homepage "{github_repo}" + version "{tag}" + license "MIT" + head "{github_repo}.git", branch: "main" + + if OS.mac? + if Hardware::CPU.arm? + url "{github_repo}/releases/download/v#{version}/vedic-darwin-aarch64.tar.gz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + elsif Hardware::CPU.intel? + url "{github_repo}/releases/download/v#{version}/vedic-darwin-x86_64.tar.gz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + else + # Unsupported platform + odie "This platform is not supported." + end + elsif OS.linux? + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "{github_repo}/releases/download/v#{version}/vedic-linux-gnu-aarch64.tar.xz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? + url "{github_repo}/releases/download/v#{version}/vedic-linux-gnu-x86_64.tar.xz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + elsif Hardware::CPU.intel? && Hardware::CPU.is_32_bit? + url "{github_repo}/releases/download/v#{version}/vedic-linux-gnu-i686.tar.xz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + elsif Hardware::CPU.arm? && Hardware::CPU.is_32_bit? + url "{github_repo}/releases/download/v#{version}/vedic-linux-gnueabihf-armv7.tar.xz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? && OS::Linux::Musl.is_detected? + url "{github_repo}/releases/download/v#{version}/vedic-linux-musl-x86_64.tar.xz" + sha256 "{sha_values.get('vedic-darwin-aarch64.tar.gz','')}" + else + # Unsupported platform + odie "This platform is not supported." + end + else + # Unsupported platform + odie "This platform is not supported." + end + + def install + bin.install "vedic" # Install the binary + end + + def caveats + <<~EOS + To get started, run: + vedic --help + EOS + end + + test do + # Simple test to verify the binary is installed + assert_match "Usage:", shell_output("#{bin}/vedic --help") + end +end""" + + +with open("pyspark-schema-generator/vedic.rb", "w", encoding="utf-8") as f: + f.write(tap_code) diff --git a/cicd/vedic.rb b/cicd/vedic.rb index 9c4f07a..6ba5687 100644 --- a/cicd/vedic.rb +++ b/cicd/vedic.rb @@ -1,57 +1,59 @@ -class vedic < Formula - desc "vedic-lang is a Sanskrit programming language" - homepage "https://github.com/vedic-lang/vedic" - version "2.0.6" - - if OS.mac? - if Hardware::CPU.arm? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-darwin-aarch64.tar.gz" - sha256 "69c2ec15825502f85478f21ce86ff64eade278a26ab70d4cf2a5299945d6e1a3" - elsif Hardware::CPU.intel? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-darwin-x86_64.tar.gz" - sha256 "f2622649af902dbc6909d1a1d2836a31cfd576daa50d0a5b1895cbc579962779" - else - # Unsupported platform - odie "This platform is not supported." - end - elsif OS.linux? - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-aarch64.tar.xz" - sha256 "0ed48b0af33f87421d0a60c5cffe831c8a1de388a103f42b666894a738fc0fff" - elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-x86_64.tar.xz" - sha256 "33b643c211121f5679636809e845354e672031814c85bb10527f4e5af4a7f18d" - elsif Hardware::CPU.intel? && Hardware::CPU.is_32_bit? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-i686.tar.xz" - sha256 "affc9a338a50021b62505076ed9544df569f2430c207bf2f82c5595403c4c34c" - elsif Hardware::CPU.arm? && Hardware::CPU.is_32_bit? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnueabihf-armv7.tar.xz" - sha256 "e4c3d44dcb75b63411e3fe844eb3c8f4e70c727a888bc2b27a6edf361b00eec4" - elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? && OS::Linux::Musl.is_detected? - url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-musl-x86_64.tar.xz" - sha256 "3b8fd6f14b7da520d06190430fbf5870418e6d93f1afc6b87f54cc1d7a4fb30b" - else - # Unsupported platform - odie "This platform is not supported." - end - else - # Unsupported platform - odie "This platform is not supported." - end - - def install - bin.install "vedic" # Install the binary - end - - def caveats - <<~EOS - To get started, run: - vedic --help - EOS - end - - test do - # Simple test to verify the binary is installed - assert_match "Usage:", shell_output("#{bin}/vedic --help") - end -end +class vedic < Formula + desc "vedic-lang is a Sanskrit programming language" + homepage "https://github.com/vedic-lang/vedic" + version "2.0.6" + license "MIT" + head "https://github.com/vedic-lang/vedic.git", branch: "main" + + if OS.mac? + if Hardware::CPU.arm? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-darwin-aarch64.tar.gz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + elsif Hardware::CPU.intel? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-darwin-x86_64.tar.gz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + else + # Unsupported platform + odie "This platform is not supported." + end + elsif OS.linux? + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-aarch64.tar.xz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-x86_64.tar.xz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + elsif Hardware::CPU.intel? && Hardware::CPU.is_32_bit? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnu-i686.tar.xz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + elsif Hardware::CPU.arm? && Hardware::CPU.is_32_bit? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-gnueabihf-armv7.tar.xz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + elsif Hardware::CPU.intel? && Hardware::CPU.is_64_bit? && OS::Linux::Musl.is_detected? + url "https://github.com/vedic-lang/vedic/releases/download/v#{version}/vedic-linux-musl-x86_64.tar.xz" + sha256 "bbd827b70e20b8ac1821b5e56d9fa5e7195327ea50a71df912c3088795b1384e" + else + # Unsupported platform + odie "This platform is not supported." + end + else + # Unsupported platform + odie "This platform is not supported." + end + + def install + bin.install "vedic" # Install the binary + end + + def caveats + <<~EOS + To get started, run: + vedic --help + EOS + end + + test do + # Simple test to verify the binary is installed + assert_match "Usage:", shell_output("#{bin}/vedic --help") + end +end \ No newline at end of file