Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能把软件发布到Homebrew么,这样更新,安装和启动都方便 #60

Open
baklpc opened this issue Apr 17, 2024 · 7 comments
Open
Labels
enhancement New feature or request

Comments

@baklpc
Copy link

baklpc commented Apr 17, 2024

能把软件发布到Homebrew么,这样更新,安装和启动都方便

@heqingpan
Copy link
Collaborator

这是一个不错的建议,我后面抽空操作下。

因为之前没有操作的经验,可能会花些时间。

@heqingpan
Copy link
Collaborator

@baklpc 已支持通过brew tap的方式安装r-nacos

首先执行brew tap r-nacos/r-nacos 把r-nacos加入taps。

然后执行brew install r-nacos 安装r-nacos。

后续可以直接通过brew upgrade r-nacos 更新到最新版本。

@baklpc
Copy link
Author

baklpc commented Apr 30, 2024

大佬牛逼

@baklpc
Copy link
Author

baklpc commented Apr 30, 2024

@baklpc 已支持通过brew tap的方式安装r-nacos

首先执行brew tap r-nacos/r-nacos 把r-nacos加入taps。

然后执行brew install r-nacos 安装r-nacos。

后续可以直接通过brew upgrade r-nacos 更新到最新版本。

大佬,Mac软件能搞一个通用版本么,现在arm的显示是intel的架构。
image

@heqingpan
Copy link
Collaborator

目前r-nacos都是使用github actions 自动编译打包。
据我所知github actions 目前还不支持Macos arm环境。
所以r-nacos暂不支持mac arm包。

另外,MacOS arm系统支持通过转译的方式运行x86应用。 虽然对性能有一定的损耗,但对r-nacos 人个日常使用来说已经足够。

所以暂时没有计划增加对arm的支持。

@baklpc
Copy link
Author

baklpc commented Apr 30, 2024

我写了一个支持brew service的rb

homebrew.rnacos.service

[Unit]
Description=Homebrew generated unit for r-nacos

[Install]
WantedBy=default.target

[Service]
Type=simple
ExecStart=/opt/homebrew/bin/rnacos
Restart=always
WorkingDirectory=/opt/homebrew/var/r-nacos

homebrew.mxcl.r-nacos.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>homebrew.mxcl.r-nacos</string>
    <key>LimitLoadToSessionType</key>
    <array>
      <string>Aqua</string>
      <string>Background</string>
      <string>LoginWindow</string>
      <string>StandardIO</string>
      <string>System</string>
    </array>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/homebrew/bin/rnacos</string>
      <string>-e</string>
      <string>/opt/homebrew/etc/r-nacos/.env</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/opt/homebrew/var/log/rnacos/error.log</string>
    <key>StandardOutPath</key>
    <string>/opt/homebrew/var/log/rnacos/output.log</string>
  </dict>
</plist>

r-nacos.rb

# Documentation: https://docs.brew.sh/Formula-Cookbook
#                https://rubydoc.brew.sh/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class RNacos < Formula
  desc "r-nacos"
  homepage "https://github.com/r-nacos/r-nacos"
  url "https://github.com/r-nacos/r-nacos/releases/download/v0.5.6/rnacos-x86_64-apple-darwin.tar.gz"
  version "v0.5.6"
  sha256 "8f156c53723d2f683f32285e40899b350f7e85c21825abef155452e8d9eded0f"
  license "Apache-2.0 license"

  # depends_on "cmake" => :build

  def install
    # ENV.deparallelize  # if your formula fails when building in parallel
    # Remove unrecognized options if warned by configure
    # https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method
    #system "./configure", *std_configure_args, "--disable-silent-rules"
    # system "cmake", "-S", ".", "-B", "build", *std_cmake_args
    bin.install "rnacos"
  end

  service do
    run [opt_bin/"rnacos"]
    keep_alive true
    working_dir var/"rnacos"
  end

  test do
    # `test do` will create, run in and delete a temporary directory.
    #
    # This test will fail and we won't accept that! For Homebrew/homebrew-core
    # this will need to be a test that verifies the functionality of the
    # software. Run the test with `brew test r-nacos`. Options passed
    # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
    #
    # The installed folder is not in the path, so use the entire path to any
    # executables being tested: `system "#{bin}/program", "do", "something"`.
    system "#{bin}/rnacos", "--version" 
  end
end

其中r-nacos.rb主要代码如下

  service do
    run [opt_bin/"rnacos"]
    keep_alive true
    working_dir var/"rnacos"
  end
image

@heqingpan
Copy link
Collaborator

赞。

之前没有用过brew service,我后面抽空试试,如果通用且方便的话就加上对service的支持。

@heqingpan heqingpan added the enhancement New feature or request label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants