Skip to content

Commit c294ae6

Browse files
committed
Initial
1 parent 769d908 commit c294ae6

34 files changed

+11202
-2
lines changed

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
paths-ignore:
8+
- '**/*.md'
9+
pull_request:
10+
branches:
11+
- '**'
12+
paths-ignore:
13+
- '**/*.md'
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
node-version: [18, 19, 20, 21, 22, 23]
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run lint
34+
run: npm run lint
35+
36+
test:
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
node-version: [18, 19, 20, 21, 22, 23]
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
50+
- name: Install dependencies
51+
run: npm ci
52+
53+
- name: Run tests
54+
run: npm run test
55+
56+
compatibility:
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
node-version: [18]
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: ${{ matrix.node-version }}
68+
69+
- name: Install dependencies
70+
run: npm ci
71+
72+
- name: Build
73+
run: npm run build
74+
75+
- name: Setup Bun
76+
uses: oven-sh/setup-bun@v1
77+
with:
78+
bun-version: latest
79+
80+
- name: Run compatibility tests
81+
run: |
82+
npm run test:compat
83+
npm run test:node
84+
bun test tests/compatibility/environment.test.ts
85+
86+
- name: Test Cloudflare Workers compatibility
87+
uses: cloudflare/wrangler-action@v3
88+
with:
89+
command: test tests/compatibility/cloudflare-workers.test.ts

.github/workflows/publish.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**/*.md'
9+
10+
jobs:
11+
bump-version:
12+
if: github.repository_owner == 'mackenly' && needs.lint.result == 'success' && needs.test.result == 'success'
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '22'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run lint
33+
run: npm run lint
34+
35+
- name: Run tests
36+
run: npm run test
37+
38+
- name: Bump version and update jsr.json
39+
id: bump_version
40+
run: |
41+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --global user.name "github-actions[bot]"
43+
# First bump the version in package.json and get the new tag
44+
new_tag=$(npm version patch --no-git-tag-version)
45+
echo "new_tag=${new_tag}" >> $GITHUB_ENV
46+
47+
# Now update jsr.json with the new version from package.json
48+
new_version=$(jq -r '.version' package.json)
49+
jq --arg new_version "$new_version" '.version = $new_version' jsr.json > jsr.tmp && mv jsr.tmp jsr.json
50+
51+
# Commit all changes and push with tag
52+
git add package.json jsr.json
53+
git commit -m "ci: bump version to $new_tag"
54+
git tag $new_tag
55+
git push origin main --follow-tags
56+
57+
publish-npm:
58+
if: success()
59+
runs-on: ubuntu-latest
60+
needs: bump-version
61+
timeout-minutes: 10
62+
permissions:
63+
contents: read
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: '22'
73+
registry-url: 'https://registry.npmjs.org'
74+
scope: '@${{ github.repository_owner }}'
75+
76+
- name: Configure npm
77+
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
78+
env:
79+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
80+
81+
- name: Install dependencies
82+
run: npm ci
83+
84+
- name: Build
85+
run: npm run build
86+
87+
- name: Publish to npm
88+
run: npm publish --access public --tag latest
89+
env:
90+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
92+
publish-github-packages:
93+
if: success()
94+
runs-on: ubuntu-latest
95+
needs: bump-version
96+
timeout-minutes: 10
97+
permissions:
98+
contents: read
99+
packages: write
100+
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v4
104+
105+
- name: Set up Node.js
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: '22'
109+
registry-url: 'https://npm.pkg.github.com'
110+
scope: '@${{ github.repository_owner }}'
111+
112+
- name: Install dependencies
113+
run: npm ci
114+
115+
- name: Build
116+
run: npm run build
117+
118+
- name: Publish to GitHub Packages
119+
run: npm publish --access public
120+
env:
121+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
123+
publish-jsr:
124+
if: success()
125+
runs-on: ubuntu-latest
126+
needs: bump-version
127+
timeout-minutes: 10
128+
permissions:
129+
contents: read
130+
id-token: write # The OIDC ID token is used for authentication with JSR.
131+
132+
steps:
133+
- name: Checkout code
134+
uses: actions/checkout@v4
135+
136+
- name: Publish to jsr
137+
run: npx jsr publish
138+
139+
create-release:
140+
if: success()
141+
runs-on: ubuntu-latest
142+
needs: bump-version
143+
timeout-minutes: 10
144+
permissions:
145+
contents: read
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Create release
152+
id: create_release
153+
uses: ncipollo/release-action@v1
154+
env:
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
with:
157+
tag: ${{ env.new_tag }}
158+
name: ${{ env.new_tag }}
159+
generateReleaseNotes: true
160+
draft: false
161+
prerelease: false

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"[typescript]": {
4+
"editor.defaultFormatter": "vscode.typescript-language-features"
5+
}
6+
}

0 commit comments

Comments
 (0)