Skip to content

Commit 59b3a46

Browse files
committed
Convert to Bun, add Justfile and release workflow
1 parent 001a18e commit 59b3a46

File tree

4 files changed

+204
-9
lines changed

4 files changed

+204
-9
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12+
13+
- uses: oven-sh/setup-bun@v2
14+
with:
15+
bun-version: latest
16+
17+
- uses: extractions/setup-just@v2
18+
19+
- uses: baptisteArno/setup-javy@v2
20+
with:
21+
javy-version: '8.0.0'
22+
1223
- uses: sqlc-dev/setup-sqlc@v4
1324
with:
1425
sqlc-version: '1.24.0'
15-
- uses: actions/setup-node@v4
16-
- run: wget https://github.com/bytecodealliance/javy/releases/download/v1.2.0/javy-x86_64-linux-v1.2.0.gz
17-
- run: gzip -d javy-x86_64-linux-v1.2.0.gz
18-
- run: chmod +x javy-x86_64-linux-v1.2.0
19-
- run: npm install
20-
- run: npx tsc --noEmit
21-
- run: npx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js
22-
- run: ./javy-x86_64-linux-v1.2.0 compile out.js -o examples/plugin.wasm
23-
- run: sqlc -f sqlc.dev.yaml diff
26+
27+
- name: Install dependencies
28+
run: bun install
29+
30+
- name: Build WASM plugin
31+
run: just plugin-wasm
32+
33+
- name: Test with sqlc
34+
run: sqlc -f sqlc.dev.yaml diff
2435
working-directory: examples

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
21+
- uses: extractions/setup-just@v2
22+
23+
- uses: baptisteArno/setup-javy@v2
24+
with:
25+
javy-version: '8.0.0'
26+
27+
- name: Install dependencies
28+
run: bun install
29+
30+
- name: Build WASM plugin
31+
run: just plugin-wasm && mv examples/plugin.wasm sqlc-gen-typescript.wasm
32+
33+
- name: Calculate SHA256
34+
id: sha256
35+
run: |
36+
SHA256=$(sha256sum sqlc-gen-typescript.wasm | awk '{print $1}')
37+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
38+
echo "SHA256: $SHA256"
39+
40+
- name: Create Release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
files: sqlc-gen-typescript.wasm
44+
body: |
45+
## sqlc-gen-typescript WASM Plugin
46+
47+
**SHA256:** `${{ steps.sha256.outputs.sha256 }}`
48+
49+
### Usage
50+
51+
Add this to your `sqlc.yaml`:
52+
53+
```yaml
54+
plugins:
55+
- name: ts
56+
wasm:
57+
url: https://github.com/pagerguild/sqlc-gen-typescript/releases/download/${{ github.ref_name }}/sqlc-gen-typescript.wasm
58+
sha256: ${{ steps.sha256.outputs.sha256 }}
59+
```
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Justfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generate examples using sqlc-dev
2+
generate: plugin-wasm
3+
cd examples && sqlc-dev -f sqlc.dev.yaml generate
4+
5+
# Compile JavaScript to WASM using javy
6+
# https://github.com/bytecodealliance/javy
7+
plugin-wasm: out-js
8+
javy build out.js -o examples/plugin.wasm
9+
10+
# Bundle TypeScript to JavaScript using esbuild
11+
out-js: codegen-proto
12+
bunx tsc --noEmit
13+
bunx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js
14+
15+
# Generate protobuf code using buf
16+
codegen-proto:
17+
buf generate --template buf.gen.yaml buf.build/sqlc/sqlc --path plugin/
18+
19+
# Clean build artifacts
20+
clean:
21+
rm -f out.js examples/plugin.wasm
22+
23+
# Build everything from scratch
24+
build: clean generate

bun.lock

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

0 commit comments

Comments
 (0)