Skip to content

Commit a2b87be

Browse files
committed
chore: add CI and JSR publishing
1 parent fdd68e7 commit a2b87be

4 files changed

Lines changed: 146 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
env:
13+
# Time parsing currently depends on local timezone (Date parsing). The test
14+
# suite expects EET/EEST semantics (UTC+2/UTC+3).
15+
TZ: Europe/Bucharest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Deno
21+
uses: denoland/setup-deno@v2
22+
with:
23+
deno-version: v2.x
24+
25+
- name: Verify formatting
26+
run: deno fmt --check
27+
28+
- name: Run linter
29+
run: deno lint
30+
31+
- name: Run tests
32+
run: deno test

.github/workflows/publish.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
publish-jsr:
10+
runs-on: ubuntu-latest
11+
env:
12+
# Keep tests deterministic (see CI workflow).
13+
TZ: Europe/Bucharest
14+
15+
permissions:
16+
contents: read
17+
id-token: write
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
29+
- name: Setup Deno
30+
uses: denoland/setup-deno@v2
31+
with:
32+
deno-version: v2.x
33+
34+
- name: Verify tag matches deno.json version
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
tag="${GITHUB_REF_NAME}"
39+
version="${tag#v}"
40+
deno_version="$(node -p "require('./deno.json').version")"
41+
if [[ "${deno_version}" != "${version}" ]]; then
42+
echo "Tag '${tag}' does not match deno.json version '${deno_version}'."
43+
exit 1
44+
fi
45+
46+
- name: Test
47+
run: deno test
48+
49+
- name: Publish to JSR
50+
run: npx jsr publish
51+
52+
github-release:
53+
runs-on: ubuntu-latest
54+
needs: [publish-jsr]
55+
56+
permissions:
57+
contents: write
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
64+
- name: Generate changelog
65+
shell: bash
66+
run: |
67+
set -euo pipefail
68+
tag="${GITHUB_REF_NAME}"
69+
70+
prev_tag="$(
71+
git tag --list "v*" --sort=-version:refname \
72+
| grep -v "^${tag}$" \
73+
| head -n 1 || true
74+
)"
75+
76+
{
77+
echo "# ${tag}"
78+
echo
79+
if [[ -n "${prev_tag}" ]]; then
80+
echo "Changes since ${prev_tag}:"
81+
echo
82+
git log --no-merges --pretty=format:"- %s (%h)" "${prev_tag}..${tag}"
83+
else
84+
echo "Changes:"
85+
echo
86+
git log --no-merges --pretty=format:"- %s (%h)" "${tag}"
87+
fi
88+
echo
89+
} > RELEASE_NOTES.md
90+
91+
- name: Create GitHub release
92+
uses: softprops/action-gh-release@v2
93+
with:
94+
name: ${{ github.ref_name }}
95+
tag_name: ${{ github.ref_name }}
96+
body_path: RELEASE_NOTES.md

deno.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
{
2+
"name": "@claudiu-ceia/ts-duckling",
3+
"version": "0.0.11",
4+
"exports": {
5+
".": "./mod.ts"
6+
},
7+
"publish": {
8+
"exclude": [
9+
".github/",
10+
"bench/",
11+
"coverage/",
12+
"docs/",
13+
"scripts/",
14+
"tests/"
15+
]
16+
},
217
"imports": {
318
"@claudiu-ceia/combine": "jsr:@claudiu-ceia/combine@0.2.8",
419
"@std/assert": "jsr:@std/assert@1.0.18",

src/ApiKey.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type ApiKeyEntity = Entity<
1414
"api_key",
1515
{
1616
provider?: string;
17-
key: string;
17+
key: string;
1818
}
1919
>;
2020

@@ -105,9 +105,9 @@ export const apiKey = (
105105

106106
export const ApiKey = createLanguageThis<ApiKeyLanguage>({
107107
/**
108-
* Matches prefix for common API key formats, e.g. "sk-" for Stripe, "pk-" for some others, etc.
108+
* Matches prefix for common API key formats, e.g. "sk-" for Stripe, "pk-" for some others, etc.
109109
* This is optional since not all API keys have a prefix.
110-
*
110+
*
111111
* Returns a provider name if a known prefix is matched, or undefined otherwise.
112112
* This allows downstream code to potentially apply provider-specific validation or parsing logic.
113113
*/

0 commit comments

Comments
 (0)