Skip to content

Commit 53ea63c

Browse files
committed
👷 add CI/CD workflows and npm/jsr build tasks
1 parent 49b8854 commit 53ea63c

12 files changed

Lines changed: 432 additions & 52 deletions

File tree

.github/workflows/preview.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: preview
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
preview:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
steps:
13+
- name: checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
submodules: true
18+
19+
- name: setup deno
20+
uses: denoland/setup-deno@v2
21+
with:
22+
deno-version: v2.x
23+
24+
- name: build wasm
25+
run: make
26+
27+
- name: Get Version
28+
id: vars
29+
run: echo ::set-output name=version::$(git describe --abbrev=0 --tags | sed 's/^v//')-pr+$(git rev-parse HEAD)
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: 20.x
35+
registry-url: https://registry.npmjs.com
36+
37+
- name: Build NPM
38+
run: deno task build:npm ${{steps.vars.outputs.version}}
39+
40+
- name: Publish Preview Versions
41+
run: npx pkg-pr-new publish './build/npm'

.github/workflows/publish.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
verify-jsr:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: checkout
17+
uses: actions/checkout@v4
18+
with:
19+
submodules: true
20+
21+
- name: setup deno
22+
uses: denoland/setup-deno@v2
23+
with:
24+
deno-version: v2.x
25+
26+
- name: build wasm
27+
run: make
28+
29+
- name: Get Version
30+
id: vars
31+
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^v//')
32+
33+
- name: Build JSR
34+
run: deno task build:jsr ${{steps.vars.outputs.version}}
35+
36+
- name: dry run publish
37+
run: npx jsr publish --dry-run --allow-dirty --token=${{secrets.JSR_TOKEN}}
38+
39+
verify-npm:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: checkout
43+
uses: actions/checkout@v4
44+
with:
45+
submodules: true
46+
47+
- name: setup deno
48+
uses: denoland/setup-deno@v2
49+
with:
50+
deno-version: v2.x
51+
52+
- name: build wasm
53+
run: make
54+
55+
- name: Get Version
56+
id: vars
57+
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^v//')
58+
59+
- name: Setup Node
60+
uses: actions/setup-node@v6
61+
with:
62+
node-version: 24
63+
64+
- name: Build NPM
65+
run: deno task build:npm ${{steps.vars.outputs.version}}
66+
67+
- name: dry run publish
68+
run: npm publish --dry-run --tag=verify
69+
working-directory: ./build/npm
70+
71+
- name: upload build
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: npm-build
75+
path: ./build/npm
76+
77+
publish-npm:
78+
needs: [verify-jsr, verify-npm]
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- name: Setup Node
83+
uses: actions/setup-node@v6
84+
with:
85+
node-version: 24
86+
87+
- name: download build
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: npm-build
91+
path: ./build/npm
92+
93+
- name: Publish NPM
94+
run: npm publish --access=public --tag=latest
95+
working-directory: ./build/npm
96+
97+
publish-jsr:
98+
needs: [verify-jsr, verify-npm]
99+
runs-on: ubuntu-latest
100+
101+
steps:
102+
- name: checkout
103+
uses: actions/checkout@v4
104+
with:
105+
submodules: true
106+
107+
- name: setup deno
108+
uses: denoland/setup-deno@v2
109+
with:
110+
deno-version: v2.x
111+
112+
- name: build wasm
113+
run: make
114+
115+
- name: Get Version
116+
id: vars
117+
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^v//')
118+
119+
- name: Build JSR
120+
run: deno task build:jsr ${{steps.vars.outputs.version}}
121+
122+
- name: Publish JSR
123+
run: npx jsr publish --allow-dirty --token=${{secrets.JSR_TOKEN}}

.github/workflows/verify.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Verify
2+
3+
on:
4+
push:
5+
branches: main
6+
pull_request:
7+
branches: main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: checkout
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
22+
- name: setup deno
23+
uses: denoland/setup-deno@v2
24+
with:
25+
deno-version: v2.x
26+
27+
- name: format
28+
run: deno task fmt:check
29+
30+
- name: lint
31+
run: deno lint
32+
33+
- name: build wasm
34+
run: make
35+
36+
- name: test
37+
run: deno task test
38+
39+
jsr:
40+
needs: test
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: checkout
44+
uses: actions/checkout@v4
45+
with:
46+
submodules: true
47+
48+
- name: setup deno
49+
uses: denoland/setup-deno@v2
50+
with:
51+
deno-version: v2.x
52+
53+
- name: Build JSR
54+
run: deno task build:jsr 0.0.0-verify.0
55+
56+
- name: dry run publish
57+
run: deno publish --dry-run
58+
59+
npm:
60+
needs: test
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: checkout
64+
uses: actions/checkout@v4
65+
with:
66+
submodules: true
67+
68+
- name: setup deno
69+
uses: denoland/setup-deno@v2
70+
with:
71+
deno-version: v2.x
72+
73+
- name: Setup Node
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: 24
77+
78+
- name: Build
79+
run: deno task build:npm 0.0.0-verify.0
80+
81+
- name: dry run publish
82+
run: npm publish --dry-run --tag=verify
83+
working-directory: ./build/npm

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/.agent-shell/
22
/clayterm.wasm
3+
/build/

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
A terminal rendering backend for [Clay](https://github.com/nicbarker/clay),
44
compiled to WebAssembly.
55

6-
With every frame, the entire UI tree is packed into a flat byte array
7-
and sent to WASM in a single call. On the C side, Clay runs layout,
8-
render commands are walked into a cell buffer, and the buffer is
9-
diffed against the previous frame. Only the cells that actually
10-
changed produce output. The result is an ANSI escape sequence that can
11-
be written directly to stdout. One trip to WASM per frame, double
12-
buffered, and only the bytes that need to change hit the output
6+
With every frame, the entire UI tree is packed into a flat byte array and sent
7+
to WASM in a single call. On the C side, Clay runs layout, render commands are
8+
walked into a cell buffer, and the buffer is diffed against the previous frame.
9+
Only the cells that actually changed produce output. The result is an ANSI
10+
escape sequence that can be written directly to stdout. One trip to WASM per
11+
frame, double buffered, and only the bytes that need to change hit the output
1312
stream.
1413

1514
Because the WASM module is pure computation with no I/O, it runs anywhere
@@ -34,7 +33,7 @@ WebAssembly does: Deno, Node, Bun, browsers, or any other runtime.
3433
## Usage
3534

3635
```typescript
37-
import { open, close, text, grow, rgba, createTerm } from "clayterm";
36+
import { close, createTerm, grow, open, rgba, text } from "clayterm";
3837

3938
const term = await createTerm({ width: 80, height: 24 });
4039

@@ -46,7 +45,10 @@ const ansi = term.render([
4645
layout: { padding: { left: 2, top: 1 } },
4746
border: {
4847
color: rgba(0, 255, 0),
49-
left: 1, right: 1, top: 1, bottom: 1,
48+
left: 1,
49+
right: 1,
50+
top: 1,
51+
bottom: 1,
5052
},
5153
cornerRadius: { tl: 1, tr: 1, bl: 1, br: 1 },
5254
}),

deno.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
{
2+
"name": "@clayterm/clayterm",
23
"tasks": {
3-
"test": "deno test --allow-read"
4+
"test": "deno test --allow-read",
5+
"fmt": "deno fmt && clang-format -i src/*.c src/*.h",
6+
"fmt:check": "deno fmt --check && clang-format --dry-run --Werror src/*.c src/*.h",
7+
"build:npm": "deno run -A tasks/build-npm.ts",
8+
"build:jsr": "deno run -A tasks/build-jsr.ts"
49
},
510
"imports": {
611
"@std/testing": "jsr:@std/testing@1",
7-
"@std/expect": "jsr:@std/expect@1"
12+
"@std/expect": "jsr:@std/expect@1",
13+
"dnt": "jsr:@deno/dnt@0.42.3"
14+
},
15+
"exports": "./mod.ts",
16+
"publish": {
17+
"include": ["*.ts", "clayterm.wasm"]
818
},
919
"fmt": {
10-
"exclude": ["clay"]
20+
"exclude": ["clay", "build"]
1121
},
1222
"lint": {
13-
"exclude": ["clay"]
23+
"exclude": ["clay", "build"]
1424
}
1525
}

0 commit comments

Comments
 (0)