Skip to content

Commit c55aa00

Browse files
allow database shell to be ran outside cli
1 parent 68d0e8d commit c55aa00

13 files changed

Lines changed: 279 additions & 19 deletions

File tree

.changeset/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
"@bunny.net/cli-darwin-x64",
1414
"@bunny.net/cli-darwin-arm64",
1515
"@bunny.net/cli-windows-x64"
16+
],
17+
[
18+
"@bunny.net/database-shell",
19+
"@bunny.net/database-shell-linux-x64",
20+
"@bunny.net/database-shell-linux-arm64",
21+
"@bunny.net/database-shell-darwin-x64",
22+
"@bunny.net/database-shell-darwin-arm64",
23+
"@bunny.net/database-shell-windows-x64"
1624
]
1725
],
1826
"linked": [],

.github/workflows/release.yml

Lines changed: 109 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ jobs:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3232

3333
version:
34-
name: Check version
34+
name: Check versions
3535
runs-on: ubuntu-latest
3636
needs: changesets
3737
if: needs.changesets.outputs.hasChangesets == 'false'
3838
outputs:
39-
cli-version: ${{ steps.check.outputs.version }}
39+
cli-version: ${{ steps.check-cli.outputs.version }}
40+
database-shell-version: ${{ steps.check-database-shell.outputs.version }}
4041
steps:
4142
- uses: actions/checkout@v4
4243
- name: Check CLI version
43-
id: check
44+
id: check-cli
4445
run: |
4546
VERSION=$(node -p "require('./packages/cli/package.json').version")
4647
PUBLISHED=$(npm view @bunny.net/cli version 2>/dev/null || echo "0.0.0")
@@ -50,8 +51,19 @@ jobs:
5051
else
5152
echo "No version change: $VERSION"
5253
fi
54+
- name: Check database-shell version
55+
id: check-database-shell
56+
run: |
57+
VERSION=$(node -p "require('./packages/database-shell/package.json').version")
58+
PUBLISHED=$(npm view @bunny.net/database-shell version 2>/dev/null || echo "0.0.0")
59+
if [ "$VERSION" != "$PUBLISHED" ]; then
60+
echo "version=$VERSION" >> $GITHUB_OUTPUT
61+
echo "New version detected: $VERSION (published: $PUBLISHED)"
62+
else
63+
echo "No version change: $VERSION"
64+
fi
5365
54-
build-binaries:
66+
build-cli-binaries:
5567
name: Build ${{ matrix.npm-pkg }}
5668
needs: version
5769
if: needs.version.outputs.cli-version
@@ -99,12 +111,60 @@ jobs:
99111
path: packages/${{ matrix.npm-pkg }}/
100112
if-no-files-found: error
101113

102-
publish:
103-
name: Publish
114+
build-database-shell-binaries:
115+
name: Build ${{ matrix.npm-pkg }}
116+
needs: version
117+
if: needs.version.outputs.database-shell-version
118+
strategy:
119+
matrix:
120+
include:
121+
- target: bun-linux-x64
122+
os: ubuntu-latest
123+
npm-pkg: database-shell-linux-x64
124+
binary: bsql
125+
- target: bun-linux-arm64
126+
os: ubuntu-latest
127+
npm-pkg: database-shell-linux-arm64
128+
binary: bsql
129+
- target: bun-darwin-x64
130+
os: macos-latest
131+
npm-pkg: database-shell-darwin-x64
132+
binary: bsql
133+
- target: bun-darwin-arm64
134+
os: macos-latest
135+
npm-pkg: database-shell-darwin-arm64
136+
binary: bsql
137+
- target: bun-windows-x64
138+
os: ubuntu-latest
139+
npm-pkg: database-shell-windows-x64
140+
binary: bsql.exe
141+
142+
runs-on: ${{ matrix.os }}
143+
144+
steps:
145+
- uses: actions/checkout@v4
146+
- uses: oven-sh/setup-bun@v2
147+
- run: bun install
148+
149+
- name: Build binary
150+
run: bun build packages/database-shell/src/cli.ts --compile --target=${{ matrix.target }} --outfile ${{ matrix.binary }}
151+
152+
- name: Prepare npm package
153+
run: cp ${{ matrix.binary }} packages/${{ matrix.npm-pkg }}/
154+
155+
- name: Upload artifact
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: ${{ matrix.npm-pkg }}
159+
path: packages/${{ matrix.npm-pkg }}/
160+
if-no-files-found: error
161+
162+
publish-cli:
163+
name: Publish CLI
104164
runs-on: ubuntu-latest
105165
needs:
106166
- version
107-
- build-binaries
167+
- build-cli-binaries
108168
steps:
109169
- uses: actions/checkout@v4
110170

@@ -159,3 +219,45 @@ jobs:
159219
npm-artifacts/cli-darwin-arm64/bunny
160220
npm-artifacts/cli-windows-x64/bunny.exe
161221
fail_on_unmatched_files: true
222+
223+
publish-database-shell:
224+
name: Publish database-shell
225+
runs-on: ubuntu-latest
226+
needs:
227+
- version
228+
- build-database-shell-binaries
229+
steps:
230+
- uses: actions/checkout@v4
231+
232+
- uses: actions/setup-node@v4
233+
with:
234+
node-version: "20"
235+
registry-url: "https://registry.npmjs.org"
236+
237+
- name: Download all platform artifacts
238+
uses: actions/download-artifact@v4
239+
with:
240+
path: npm-artifacts
241+
242+
- name: Copy binaries into npm packages
243+
run: |
244+
for pkg in database-shell-linux-x64 database-shell-linux-arm64 database-shell-darwin-x64 database-shell-darwin-arm64 database-shell-windows-x64; do
245+
cp -r npm-artifacts/$pkg/* packages/$pkg/
246+
done
247+
248+
- name: Publish platform packages
249+
run: |
250+
for pkg in database-shell-linux-x64 database-shell-linux-arm64 database-shell-darwin-x64 database-shell-darwin-arm64 database-shell-windows-x64; do
251+
cd packages/$pkg
252+
npm publish --access public
253+
cd ../..
254+
done
255+
env:
256+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
257+
258+
- name: Publish @bunny.net/database-shell
259+
run: |
260+
cd packages/database-shell
261+
npm publish --access public
262+
env:
263+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3939
# Bunny CLI local context
4040
.bunny
4141
bunny
42+
bsql

bun.lock

Lines changed: 47 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"module": "src/index.ts",
66
"bin": {
7-
"bunny": "./bin/bunny.js"
7+
"bunny": "./bin/bunny.cjs"
88
},
99
"files": ["bin"],
1010
"devDependencies": {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@bunny.net/database-shell-darwin-arm64",
3+
"version": "0.0.0",
4+
"description": "bunny.net database shell binary for macOS arm64",
5+
"os": ["darwin"],
6+
"cpu": ["arm64"],
7+
"files": ["bsql"],
8+
"publishConfig": {
9+
"access": "public"
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@bunny.net/database-shell-darwin-x64",
3+
"version": "0.0.0",
4+
"description": "bunny.net database shell binary for macOS x64",
5+
"os": ["darwin"],
6+
"cpu": ["x64"],
7+
"files": ["bsql"],
8+
"publishConfig": {
9+
"access": "public"
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@bunny.net/database-shell-linux-arm64",
3+
"version": "0.0.0",
4+
"description": "bunny.net database shell binary for Linux arm64",
5+
"os": ["linux"],
6+
"cpu": ["arm64"],
7+
"files": ["bsql"],
8+
"publishConfig": {
9+
"access": "public"
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@bunny.net/database-shell-linux-x64",
3+
"version": "0.0.0",
4+
"description": "bunny.net database shell binary for Linux x64",
5+
"os": ["linux"],
6+
"cpu": ["x64"],
7+
"files": ["bsql"],
8+
"publishConfig": {
9+
"access": "public"
10+
}
11+
}

0 commit comments

Comments
 (0)