Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Type check
run: deno task check

- name: Lint
run: deno task lint

- name: Format check
run: deno fmt --check
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
publish_jsr:
if: github.repository == 'openstatusHQ/sdk-node'
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -23,6 +24,7 @@ jobs:
- name: Publish package
run: deno publish
publish_npm:
if: github.repository == 'openstatusHQ/sdk-node'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/regen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: regen

on:
schedule:
- cron: "0 8 * * 1"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
regen:
name: regenerate from latest schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

# buf is not a dependency of this repo; deno task generate shells out to it
- uses: bufbuild/buf-action@v1
with:
setup_only: true

# buf.gen.yaml resolves buf.build/openstatus/api:main, so this diffs
# exactly when the schema moved
- name: Generate
run: deno task generate

# the committed tree is formatted; without this every run diffs the whole
# of src/gen on line wrapping alone
- name: Format generated code
run: deno fmt src/gen

- name: Type check
run: deno task check

# gated on a real diff — an unconditional bump would dirty the tree every
# run and open a weekly PR containing nothing but a version line
- name: Bump patch version
run: |
if git diff --quiet -- src/gen; then
echo "no schema change; skipping version bump"
exit 0
fi
cur=$(grep -oP '"version": "\K[^"]+' deno.json)
IFS=. read -r maj min pat <<< "$cur"
next="$maj.$min.$((pat + 1))"
# sed, not jq — jq re-serialises the whole file and dirties unrelated lines
sed -i -E "0,/\"version\": \"[^\"]+\"/s//\"version\": \"$next\"/" deno.json
echo "bumped $cur -> $next"

- name: Open PR if anything changed
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.SDK_BOT_TOKEN || github.token }}
branch: regen/schema
delete-branch: true
commit-message: "chore: regen src/gen from latest schema"
title: "chore: regen src/gen from latest schema"
body: |
Automated regen of `src/gen` from `buf.build/openstatus/api:main`.

Merging this only updates generated code — bump the package version
separately when cutting a release.
4 changes: 4 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
"lint": "deno lint",
"fmt": "deno fmt"
},
"lint": {
"exclude": ["src/gen/"]
},
"imports": {
"@deno/dnt": "jsr:@deno/dnt@0.42.3",
"@bufbuild/protobuf": "npm:@bufbuild/protobuf@^2.11.0",
"@connectrpc/connect": "npm:@connectrpc/connect@^2.1.1",
"@connectrpc/connect-web": "npm:@connectrpc/connect-web@^2.1.1"
Expand Down
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions scripts/build_npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { build, emptyDir } from "jsr:@deno/dnt@0.42.3";
import { build, emptyDir } from "@deno/dnt";
import denoJson from "../deno.json" with { type: "json" };

await emptyDir("./npm");

Expand All @@ -12,7 +13,7 @@ await build({
package: {
// package.json properties
name: "@openstatus/sdk-node",
version: "0.2.0",
version: denoJson.version,
description: "SDK for openstatus.",
license: "MIT",
repository: {
Expand Down