feat: add Homebrew formula for dbx-cli
This commit is contained in:
parent
700e06d57e
commit
59d2dd7c87
|
|
@ -230,3 +230,103 @@ jobs:
|
|||
exit 0
|
||||
fi
|
||||
pnpm --filter "${PACKAGE_FILTER}" publish --access public --provenance --no-git-checks
|
||||
|
||||
publish-homebrew-formula:
|
||||
name: Publish Homebrew formula
|
||||
runs-on: ubuntu-latest
|
||||
needs: publish-leaf-packages
|
||||
steps:
|
||||
- name: Download CLI npm tarball and compute SHA256
|
||||
id: cli-hash
|
||||
env:
|
||||
VERSION: ${{ needs.prepare.outputs.version }}
|
||||
run: |
|
||||
VERSION="${VERSION}"
|
||||
NPM_TARBALL="cli-${VERSION}.tgz"
|
||||
NPM_URL="https://registry.npmjs.org/@dbx-app/cli/-/${NPM_TARBALL}"
|
||||
|
||||
# Poll npm until the package is available (CDN propagation delay)
|
||||
for i in $(seq 1 12); do
|
||||
if curl -fsSLI "${NPM_URL}" >/dev/null 2>&1; then
|
||||
echo "Package found on attempt ${i}"
|
||||
break
|
||||
fi
|
||||
echo "Waiting for npm CDN (attempt ${i}/12)..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
curl -fsSL -o "${NPM_TARBALL}" "${NPM_URL}"
|
||||
CLI_SHA256=$(sha256sum "${NPM_TARBALL}" | cut -d ' ' -f 1)
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "sha256=${CLI_SHA256}" >> "$GITHUB_OUTPUT"
|
||||
echo " cli version: ${VERSION}"
|
||||
echo " sha256: ${CLI_SHA256}"
|
||||
|
||||
- name: Push formula to homebrew-tap
|
||||
env:
|
||||
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
|
||||
CLI_VERSION: ${{ steps.cli-hash.outputs.version }}
|
||||
CLI_SHA256: ${{ steps.cli-hash.outputs.sha256 }}
|
||||
run: |
|
||||
git clone --depth 1 \
|
||||
"https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/t8y2/homebrew-tap.git" \
|
||||
homebrew-tap
|
||||
cd homebrew-tap
|
||||
mkdir -p Formula
|
||||
|
||||
cat > Formula/dbx-cli.rb <<'RUBY_EOF'
|
||||
class DbxCli < Formula
|
||||
desc "Command-line interface for DBX database connections, schema, and safe queries"
|
||||
homepage "https://github.com/t8y2/dbx"
|
||||
url "https://registry.npmjs.org/@dbx-app/cli/-/cli-__CLI_VERSION__.tgz"
|
||||
sha256 "__CLI_SHA256__"
|
||||
license "Apache-2.0"
|
||||
|
||||
depends_on "node"
|
||||
|
||||
on_linux do
|
||||
depends_on "pkgconf" => :build
|
||||
depends_on "libsecret"
|
||||
end
|
||||
|
||||
def install
|
||||
system "npm", "install", *std_npm_args
|
||||
bin.install_symlink libexec.glob("bin/*")
|
||||
|
||||
# Rebuild better-sqlite3 and keytar native bindings for the current platform.
|
||||
# prebuild-install is blocked by the Homebrew sandbox during npm install,
|
||||
# so we must rebuild them explicitly via node-gyp.
|
||||
node_modules = libexec/"lib/node_modules/@dbx-app/cli/node_modules"
|
||||
|
||||
cd node_modules/"better-sqlite3" do
|
||||
system "npm", "run", "build-release"
|
||||
end
|
||||
|
||||
cd node_modules/"keytar" do
|
||||
rm_r "prebuilds" if File.directory?("prebuilds")
|
||||
system "npm", "run", "build"
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
assert_path_exists bin/"dbx"
|
||||
system bin/"dbx", "doctor"
|
||||
end
|
||||
end
|
||||
RUBY_EOF
|
||||
|
||||
sed -i 's/^ //' Formula/dbx-cli.rb
|
||||
sed -i "s/__CLI_VERSION__/${CLI_VERSION}/g" Formula/dbx-cli.rb
|
||||
sed -i "s/__CLI_SHA256__/${CLI_SHA256}/g" Formula/dbx-cli.rb
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add Formula/dbx-cli.rb
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "CLI Homebrew formula is already up to date."
|
||||
else
|
||||
git commit -m "dbx-cli ${CLI_VERSION}"
|
||||
git push
|
||||
echo "::notice::CLI Homebrew formula updated to ${CLI_VERSION}"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ DBX also provides a dedicated CLI package for terminal, script, and Codex workfl
|
|||
|
||||
```bash
|
||||
npm install -g @dbx-app/cli
|
||||
# or via Homebrew
|
||||
brew tap t8y2/dbx && brew install dbx-cli
|
||||
dbx connections list --json
|
||||
dbx query local "select 1" --json
|
||||
```
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ DBX 也提供独立 CLI 包,适合终端、脚本和 Codex 工作流:
|
|||
|
||||
```bash
|
||||
npm install -g @dbx-app/cli
|
||||
# 或通过 Homebrew
|
||||
brew tap t8y2/dbx && brew install dbx-cli
|
||||
dbx connections list --json
|
||||
dbx query local "select 1" --json
|
||||
```
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
class DbxCli < Formula
|
||||
desc "Command-line interface for DBX database connections, schema, and safe queries"
|
||||
homepage "https://github.com/t8y2/dbx"
|
||||
url "https://registry.npmjs.org/@dbx-app/cli/-/cli-0.4.7.tgz"
|
||||
sha256 "d507138dc5bd9611ad1e668a14e5a099754e8a1a3994742f2d03dbc22da911d8"
|
||||
license "Apache-2.0"
|
||||
|
||||
depends_on "node"
|
||||
|
||||
on_linux do
|
||||
depends_on "pkgconf" => :build
|
||||
depends_on "libsecret"
|
||||
end
|
||||
|
||||
def install
|
||||
system "npm", "install", *std_npm_args
|
||||
bin.install_symlink libexec.glob("bin/*")
|
||||
|
||||
# Rebuild better-sqlite3 and keytar native bindings for the current platform.
|
||||
# prebuild-install is blocked by the Homebrew sandbox during npm install,
|
||||
# so we must rebuild them explicitly via node-gyp.
|
||||
node_modules = libexec/"lib/node_modules/@dbx-app/cli/node_modules"
|
||||
|
||||
cd node_modules/"better-sqlite3" do
|
||||
system "npm", "run", "build-release"
|
||||
end
|
||||
|
||||
cd node_modules/"keytar" do
|
||||
rm_r "prebuilds" if File.directory?("prebuilds")
|
||||
system "npm", "run", "build"
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
assert_path_exists bin/"dbx"
|
||||
system bin/"dbx", "doctor"
|
||||
end
|
||||
end
|
||||
|
|
@ -11,6 +11,13 @@ description: 在终端、脚本、CI 和 Codex 中使用 DBX 连接。
|
|||
npm install -g @dbx-app/cli
|
||||
```
|
||||
|
||||
### Homebrew
|
||||
|
||||
```bash
|
||||
brew tap t8y2/dbx
|
||||
brew install dbx-cli
|
||||
```
|
||||
|
||||
需要 Node.js 22.13.0 或更高版本。
|
||||
|
||||
查看版本:
|
||||
|
|
|
|||
|
|
@ -7,10 +7,19 @@ description: Use DBX connections from terminals, scripts, CI, and Codex.
|
|||
|
||||
## Install
|
||||
|
||||
### npm
|
||||
|
||||
```bash
|
||||
npm install -g @dbx-app/cli
|
||||
```
|
||||
|
||||
### Homebrew
|
||||
|
||||
```bash
|
||||
brew tap t8y2/dbx
|
||||
brew install dbx-cli
|
||||
```
|
||||
|
||||
Requires Node.js 22.13.0 or newer.
|
||||
|
||||
Check the installed version:
|
||||
|
|
|
|||
|
|
@ -4,10 +4,19 @@ Command line interface for DBX database connections, schema inspection, safe que
|
|||
|
||||
## Install
|
||||
|
||||
### npm
|
||||
|
||||
```bash
|
||||
npm install -g @dbx-app/cli
|
||||
```
|
||||
|
||||
### Homebrew
|
||||
|
||||
```bash
|
||||
brew tap t8y2/dbx
|
||||
brew install dbx-cli
|
||||
```
|
||||
|
||||
Requires Node.js 22.13.0 or newer.
|
||||
|
||||
## Usage
|
||||
|
|
|
|||
Loading…
Reference in New Issue