Skip to content

Commit 8f0439b

Browse files
committed
feat: prepare library for npm publishing
- Add npm publishing metadata (description, repository, homepage, bugs) - Add files field to explicitly include only library files - Add prepublishOnly script for build/test before publish - Add .npmignore to exclude tests, demos, and dev files - Add publish.yml workflow for Trusted Publishing (OIDC) - Add LICENSE, CHANGELOG.md, and RELEASING.md - Update version to 0.1.0
1 parent 43afc0f commit 8f0439b

File tree

7 files changed

+285
-6
lines changed

7 files changed

+285
-6
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Publish to npm using Trusted Publishing (OIDC)
2+
# No NPM_TOKEN secret required - uses GitHub's OIDC provider
3+
# Triggered manually when a release is published
4+
5+
name: Publish to npm
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
16+
contents: read
17+
steps:
18+
- run: corepack enable
19+
- uses: actions/checkout@v4
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
registry-url: 'https://registry.npmjs.org'
25+
cache: 'yarn'
26+
- name: Install dependencies
27+
run: yarn install
28+
- name: Build
29+
run: yarn build
30+
- name: Test
31+
run: yarn test
32+
- name: Publish to npm
33+
run: npm publish --provenance --access public

.npmignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Test files
2+
__tests__/
3+
4+
# Demo files (not needed by consumers)
5+
src/Demo.res
6+
src/Demo.res.mjs
7+
src/Demo_AStar.res
8+
src/Demo_AStar.res.mjs
9+
src/iter_test.res
10+
src/iter_test.res.mjs
11+
12+
# GitHub
13+
.github/
14+
15+
# IDE/Editor
16+
.vscode/
17+
.idea/
18+
19+
# Documentation (internal)
20+
CLAUDE.md
21+
AGENTS.md
22+
CHANGELOG.md
23+
RELEASING.md
24+
25+
# Git
26+
.gitignore
27+
28+
# Yarn
29+
.yarn/
30+
.yarnrc.yml
31+
yarn.lock
32+
33+
# Build artifacts
34+
lib/
35+
coverage/
36+
*.lock
37+
.bsb.lock
38+
rewatch.lock
39+
rescript.lock
40+
41+
# OS
42+
.DS_Store
43+
44+
# Graph output files
45+
*.gexf
46+
*.cyc
47+
*.svg
48+
*.xgr
49+
50+
# Claude settings
51+
.claude/

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-01-30
9+
10+
### Added
11+
12+
- Initial release with comprehensive ReScript bindings for Graphology
13+
- **Core Graph Operations**: Full CRUD operations for nodes and edges with attributes
14+
- **Graph Types**: Support for directed, undirected, multi-graphs, and mixed graphs
15+
- **Algorithms**:
16+
- Shortest path: Dijkstra, A*, unweighted (bidirectional & single-source)
17+
- Simple path algorithms
18+
- Graph traversal: BFS, DFS
19+
- **Layout Algorithms**: Circular, CirclePack, Rotation
20+
- **Graph Generators**: Complete, path, cycle, clique, star, karate club, etc.
21+
- **Import/Export**: GEXF format and SVG rendering
22+
- **Iterator Support**: Native JavaScript Iterator protocol for nodes, edges, and neighbors
23+
- **Utility Functions**: Graph merging, key renaming, type inference
24+
25+
### Technical Details
26+
27+
- Built for ReScript v12.x with ES modules
28+
- Functor-based architecture for type safety
29+
- 532 passing tests with comprehensive coverage
30+
- Verified against official Graphology API documentation

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Danny Siu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe("Graph Tests", () => {
222222

223223
## Requirements
224224

225-
- ReScript v12.0.0-rc.5 or later
225+
- ReScript v12.x or later
226226
- Graphology v0.26.0 or later
227227
- Node.js with ES module support
228228

RELEASING.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Releasing
2+
3+
This document describes how to release new versions of `@dsiu/rescript-graphology`.
4+
5+
## Prerequisites
6+
7+
- You must be logged in to npm: `npm whoami`
8+
- You must have publish access to the `@dsiu` scope on npm
9+
10+
## One-Time Setup: Trusted Publishing
11+
12+
This package uses [npm Trusted Publishing](https://docs.npmjs.com/generating-provenance-statements) with GitHub Actions OIDC. This eliminates the need for npm tokens stored as secrets.
13+
14+
### Configure Trusted Publishing on npmjs.com
15+
16+
1. Go to [npmjs.com](https://www.npmjs.com) and log in
17+
2. Navigate to your package: `@dsiu/rescript-graphology`
18+
3. Go to **Settings** > **Publishing access**
19+
4. Under **Trusted Publishing**, click **Add a trusted publisher**
20+
5. Configure:
21+
- **Repository owner**: `dsiu`
22+
- **Repository name**: `rescript-graphology`
23+
- **Workflow filename**: `publish.yml`
24+
- **Environment**: (leave blank)
25+
6. Click **Add**
26+
27+
> **Note**: You must publish the package manually at least once before you can configure Trusted Publishing.
28+
29+
## Release Process
30+
31+
### 1. Update Version
32+
33+
```bash
34+
# Update version in package.json
35+
npm version patch # or minor, major
36+
```
37+
38+
This will:
39+
- Update `package.json` version
40+
- Create a git commit
41+
- Create a git tag
42+
43+
### 2. Push Changes and Tag
44+
45+
```bash
46+
git push origin main --tags
47+
```
48+
49+
### 3. Create GitHub Release
50+
51+
```bash
52+
# Create a release (this triggers the publish workflow)
53+
gh release create v0.1.0 --title "v0.1.0" --notes "See CHANGELOG.md for details"
54+
```
55+
56+
Or create the release via GitHub UI:
57+
1. Go to **Releases** > **Create a new release**
58+
2. Choose the tag you just pushed
59+
3. Add release title and notes
60+
4. Click **Publish release**
61+
62+
The `publish.yml` workflow will automatically:
63+
- Run tests
64+
- Publish to npm with provenance
65+
66+
## First-Time Manual Publish
67+
68+
For the very first publish (before Trusted Publishing is configured):
69+
70+
```bash
71+
# Ensure you're logged in
72+
npm whoami
73+
74+
# Build and test
75+
yarn clean && yarn build && yarn test
76+
77+
# Publish (first time only)
78+
npm publish --access public
79+
```
80+
81+
After the first publish, configure Trusted Publishing as described above.
82+
83+
## Manual Publishing (Fallback)
84+
85+
If you need to publish manually (e.g., Trusted Publishing issues):
86+
87+
```bash
88+
# Login to npm
89+
npm login
90+
91+
# Build and test
92+
yarn clean && yarn build && yarn test
93+
94+
# Publish
95+
npm publish --access public
96+
```
97+
98+
## Verifying the Release
99+
100+
After publishing:
101+
102+
1. Check npm: `npm view @dsiu/rescript-graphology`
103+
2. Verify provenance badge on npmjs.com package page
104+
3. Test installation in a new project:
105+
```bash
106+
mkdir test-install && cd test-install
107+
npm init -y
108+
npm install @dsiu/rescript-graphology
109+
```
110+
111+
## Version Guidelines
112+
113+
- **Patch** (0.0.x): Bug fixes, documentation updates
114+
- **Minor** (0.x.0): New features, non-breaking changes
115+
- **Major** (x.0.0): Breaking changes
116+
117+
For pre-1.0 releases, minor versions may include breaking changes.

package.json

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
{
22
"name": "@dsiu/rescript-graphology",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
4+
"description": "Type-safe ReScript bindings for Graphology, a robust JavaScript graph library",
45
"type": "module",
56
"packageManager": "[email protected]",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/dsiu/rescript-graphology.git"
10+
},
11+
"homepage": "https://github.com/dsiu/rescript-graphology#readme",
12+
"bugs": {
13+
"url": "https://github.com/dsiu/rescript-graphology/issues"
14+
},
615
"scripts": {
716
"build": "rescript build .",
817
"watch": "rescript watch .",
918
"clean": "rescript clean .",
10-
"test": "jest"
19+
"test": "jest",
20+
"prepublishOnly": "yarn clean && yarn build && yarn test"
1121
},
22+
"files": [
23+
"src/Graphology*.res",
24+
"src/Graphology*.resi",
25+
"src/Graphology*.res.mjs",
26+
"rescript.json",
27+
"README.md",
28+
"LICENSE"
29+
],
1230
"keywords": [
13-
"rescript"
31+
"rescript",
32+
"graphology",
33+
"graph",
34+
"network",
35+
"data-structure",
36+
"algorithms",
37+
"shortest-path",
38+
"dijkstra",
39+
"bfs",
40+
"dfs",
41+
"traversal"
1442
],
15-
"author": "Danny Siu <[email protected]>",
43+
"author": "Danny Siu",
1644
"license": "MIT",
1745
"jest": {
1846
"testMatch": [
@@ -62,7 +90,6 @@
6290
"graphology-svg": "^0.1.3",
6391
"graphology-traversal": "^0.3.1",
6492
"graphology-types": "^0.24.0",
65-
"rescript": "^12.2.0-rc.1",
6693
"rescript-nodejs": "^16.1.0"
6794
}
6895
}

0 commit comments

Comments
 (0)