@@ -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")
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 }}
0 commit comments