8000 ci: Add publish workflow and publish to NPM · aklinker1/zeta@c236660 · GitHub
[go: up one dir, main page]

Skip to content

Commit c236660

Browse files
committed
ci: Add publish workflow and publish to NPM
1 parent 77129d0 commit c236660

5 files changed

Lines changed: 95 additions & 13 deletions

File tree

‎.github/actions/setup/action.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Basic Setup
2+
description: Install tools and dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
8+
with:
9+
bun-version-file: "package.json"
10+
- run: bun install --frozen-lockfile
11+
shell: bash

‎.github/workflows/publish.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
validate:
7+
name: Validate
8+
uses: "./.github/workflows/validate.yml"
9+
secrets: inherit
10+
publish:
11+
name: Publish
12+
runs-on: ubuntu-24.04
13+
needs: [validate]
14+
permissions:
15+
contents: write # Allow pushing
16+
id-token: write # Enable OIDC for NPM and JSR
17+
steps:
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
with:
20+
fetch-depth: 0
21+
- uses: ./.github/actions/setup
22+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
23+
- run: sudo npm i -g npm@latest
24+
- run: bun run build
25+
- run: bunx jsr publish --dry-run
26+
# - run: npm publish --dry-run # NPM fails with " npm error You cannot publish over the previously published versions: X.Y.Z."
27+
- run: |
28+
git config --global user.name "github-actions[bot]"
29+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
30+
- run: bunx changelogen@latest --release --push
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- run: npm publish
34+
- name: Sync JSR version
35+
run: |
36+
node -e 'const fs = require("fs"); const ver = require("./package.json").version; let content = fs.readFileSync("jsr.json", "utf8"); fs.writeFileSync("jsr.json", content.replace(/(version"\s*:\s*")[^"]*(")/, `$1${ver}$2`))'
37+
git add jsr.json
38+
git commit -m "sync \`jsr.json\` version"
39+
git push
40+
- run: bunx jsr publish

‎.github/workflows/validate.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Validate
2+
on:
3+
pull_request:
4+
workflow_call:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
checks:
12+
name: Checks
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
16+
- uses: ./.github/actions/setup
17+
- run: bun run build
18+
- run: bun check
19+
tests:
20+
name: Tests
21+
runs-on: ubuntu-24.04
22+
steps:
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
- uses: ./.github/actions/setup
25+
- run: bun test

‎CONTRIBUTING.md‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,3 @@ bun run bench
2121
# Start an example app
2222
bun run example
2323
```
24-
25-
## Publishing
26-
27-
To publish a new version of Zeta, run:
28-
29-
```sh
30-
bun run publish X.Y.Z
31-
```
32-
33-
`patch`, `minor`, and `major` cannot be passed into the `publish` script.

‎package.json‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
{
2-
"name": "zeta",
2+
"name": "@aklinker1/zeta",
33
"version": "1.0.0",
4+
"type": "module",
45
"license": "MIT",
56
"packageManager": "bun@1.2.17",
67
"module": "src/index.ts",
78
"types": "src/index.ts",
8-
"type": "module",
9+
"exports": {
10+
".": "./src/index.ts",
11+
"./types": "./src/types.ts",
12+
"./client": "./src/client.ts",
13+
"./testing": "./src/testing.ts",
14+
"./adapters/zod-schema-adapter": "./src/adapters/zod-schema-adapter.ts"
15+
},
16+
"files": [
17+
"src"
18+
],
19+
"publishConfig": {
20+
"access": "public"
21+
},
22+
"repository": {
23+
"url": "https://github.com/aklinker1/zeta"
24+
},
925
"scripts": {
1026
"dev": "bun test --watch",
1127
"bench": "bun run src/__tests__/bench.ts",
@@ -39,4 +55,4 @@
3955
"vitepress-plugin-mermaid": "^2.0.17",
4056
"zod": "^4.1.11"
4157
}
42-
}
58+
}

0 commit comments

Comments
 (0)
0