Skip to content
Merged
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
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Publishes to npm when a tag like v1.2.3 is pushed and matches package.json.
# Uses npm trusted publishing (OIDC) if configured on npmjs.com for this
# repository and workflow; otherwise set an NPM_TOKEN repository secret.
name: release
on:
push:
tags: ["v*"]
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm install -g npm@latest
- run: bun install --frozen-lockfile
- run: bun run typecheck
- run: bun test
- run: bun run smoke
- name: Check that the tag matches package.json
run: test "v$(node -p 'require("./package.json").version')" = "${GITHUB_REF_NAME}"
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ bun run build # dist/ with ESM and type declarations
bun run smoke # build, then import dist/ from Node
```

Installing straight from GitHub also works (`npm install github:carsonfarmer/geometric-tree`):
the `prepare` script builds `dist/` on install. To release, bump `version` in `package.json`,
then push a matching tag (`git tag v0.2.0 && git push --tags`); the release workflow tests,
builds and publishes to npm with provenance.

## References

- Carson Farmer and Aljoscha Meyer. *Geometric Search Trees.* https://g-trees.github.io/g_trees/
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@
"scripts": {
"test": "bun test",
"typecheck": "tsc --noEmit",
"build": "bun build src/index.ts --outdir dist --target node && tsc -p tsconfig.build.json",
"build": "tsc -p tsconfig.build.json",
"prepare": "tsc -p tsconfig.build.json",
"smoke": "bun run build && node test/node.mjs",
"bench": "bun run bench/bench.ts"
},
"devDependencies": {
"@types/bun": "^1.4.2",
"typescript": "^5"
},
"main": "dist/index.js"
"main": "dist/index.js",
"publishConfig": {
"access": "public",
"provenance": true
}
}
6 changes: 3 additions & 3 deletions src/gk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* conversion happens in both directions at the same threshold, so the
* representation remains a function of the stored set alone.
*/
import { hashed, type Rank } from "./rank";
import type { ItemsFactory, Options } from "./options";
import { hashed, type Rank } from "./rank.js";
import type { ItemsFactory, Options } from "./options.js";
import {
ArrayItems,
entries,
Expand All @@ -29,7 +29,7 @@ import {
type Entry,
type Items,
type Tree,
} from "./tree";
} from "./tree.js";

/** One dimension of a Gk-tree: how its inner trees rank, weigh and nest. */
export type Dimension<K> = {
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from "./tree";
export * as binary from "./binary";
export * from "./rank";
export { type ItemsFactory, type Options } from "./options";
export { gk, GkItems, TreeItems } from "./gk";
export { GMap } from "./map";
export { GSet } from "./set";
export { GList, at, splitAt, type Seq } from "./list";
export * from "./tree.js";
export * as binary from "./binary.js";
export * from "./rank.js";
export { type ItemsFactory, type Options } from "./options.js";
export { gk, GkItems, TreeItems } from "./gk.js";
export { GMap } from "./map.js";
export { GSet } from "./set.js";
export { GList, at, splitAt, type Seq } from "./list.js";
4 changes: 2 additions & 2 deletions src/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { random, type Rank } from "./rank";
import { random, type Rank } from "./rank.js";
import {
ArrayItems,
entries,
Expand All @@ -8,7 +8,7 @@ import {
zip,
type Entry,
type Tree,
} from "./tree";
} from "./tree.js";

/**
* A G-tree used as a sequence: positions replace keys, and node sizes guide
Expand Down
4 changes: 2 additions & 2 deletions src/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config, type Config, type Options } from "./options";
import { config, type Config, type Options } from "./options.js";
import {
entries,
find,
Expand All @@ -8,7 +8,7 @@ import {
size,
type Entry,
type Tree,
} from "./tree";
} from "./tree.js";

/** An immutable, ordered map. Every update returns a new map. */
export class GMap<K, V> implements Iterable<[K, V]> {
Expand Down
4 changes: 2 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hashed, type Rank } from "./rank";
import { ArrayItems, type Compare, type Items } from "./tree";
import { hashed, type Rank } from "./rank.js";
import { ArrayItems, type Compare, type Items } from "./tree.js";

/** Creates the empty inner set for a node of a tree keyed by `K`. */
export type ItemsFactory<K> = <V>() => Items<K, V>;
Expand Down
4 changes: 2 additions & 2 deletions src/set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config, type Config, type Options } from "./options";
import { config, type Config, type Options } from "./options.js";
import {
entries,
find,
Expand All @@ -8,7 +8,7 @@ import {
size,
type Entry,
type Tree,
} from "./tree";
} from "./tree.js";

/** An immutable, ordered set. Every update returns a new set. */
export class GSet<K> implements Iterable<K> {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist"
},
"include": ["src"]
Expand Down
Loading