Skip to content

Commit 3d11109

Browse files
authored
Merge pull request #2 from PSPDFKit-labs/fix/html-input-conversion
chore: add changelog-driven npm + GitHub release workflow
2 parents d7e3cbd + a03d7f1 commit 3d11109

File tree

8 files changed

+161
-5
lines changed

8 files changed

+161
-5
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
registry-url: "https://registry.npmjs.org"
24+
cache: "pnpm"
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
31+
- name: Install
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Validate
35+
run: |
36+
pnpm run lint
37+
pnpm test
38+
39+
- name: Verify tag matches package version
40+
run: |
41+
TAG_VERSION="${GITHUB_REF_NAME#v}"
42+
PKG_VERSION=$(node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));process.stdout.write(p.version)")
43+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
44+
echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
45+
exit 1
46+
fi
47+
48+
- name: Publish npm package
49+
run: npm publish --access public --provenance
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
53+
- name: Create GitHub release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
generate_release_notes: true

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented in this file.
4+
5+
The format is based on Keep a Changelog, and this project follows Semantic Versioning.
6+
7+
## [Unreleased]
8+
9+
### Added
10+
- GitHub tag-based release workflow for automated npm publish and GitHub release creation.
11+
- Release runbook (`RELEASING.md`) and version sync script for plugin manifest consistency.
12+
13+
## [0.1.1] - 2026-02-28
14+
15+
### Fixed
16+
- Normalized `nutrient_extract_text.language` schema to avoid OpenClaw schema validation errors (`array schema missing items`).
17+
- Preserved multi-language OCR support by accepting comma-separated language strings.
18+
- Added support for HTML inputs in `nutrient_convert_to_pdf`.
19+
20+
### Changed
21+
- Simplified request `User-Agent` to `NutrientOpenClawPlugin` to avoid hardcoded version churn in code/tests.
22+
23+
## [0.1.0] - 2026-02-04
24+
25+
### Added
26+
- Initial release of `@nutrient-sdk/nutrient-openclaw`.
27+
- Core tools: conversion, extraction, OCR, redaction, signing, watermarking, and credits checks.

RELEASING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Releasing
2+
3+
This repository uses npm + GitHub tags for releases.
4+
5+
## Prerequisites
6+
7+
- Push access to `PSPDFKit-labs/nutrient-openclaw`
8+
- npm publish access to `@nutrient-sdk/nutrient-openclaw`
9+
- `NPM_TOKEN` configured in GitHub repo secrets (automation token)
10+
11+
## Release Flow
12+
13+
1. Ensure `main` is clean and up to date.
14+
2. Update `CHANGELOG.md`:
15+
- Move relevant items from `Unreleased` into a new version section.
16+
- Keep entries concise and user-visible.
17+
3. Bump version and create tag:
18+
19+
```bash
20+
npm version patch
21+
```
22+
23+
This runs:
24+
- `preversion`: lint + tests
25+
- `version`: syncs `openclaw.plugin.json` version to match `package.json`
26+
27+
4. Push commit and tag:
28+
29+
```bash
30+
git push origin main
31+
git push origin --tags
32+
```
33+
34+
5. GitHub Actions release workflow runs on tag `v*.*.*`:
35+
- installs dependencies
36+
- runs lint + tests
37+
- verifies tag matches `package.json` version
38+
- publishes to npm with provenance
39+
- creates GitHub release
40+
41+
## Notes
42+
43+
- If you need a non-patch release, use `npm version minor` or `npm version major`.
44+
- If the workflow fails at publish, verify `NPM_TOKEN` permissions for the `@nutrient-sdk` scope.

openclaw.plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "nutrient-openclaw",
33
"name": "Nutrient Document Processing",
44
"description": "Process, convert, sign, redact, OCR, and extract data from documents via the Nutrient DWS API.",
5-
"version": "0.1.0",
5+
"version": "0.1.1",
66
"repository": "github:PSPDFKit-labs/nutrient-openclaw",
77
"configSchema": {
88
"type": "object",

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nutrient-sdk/nutrient-openclaw",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "OpenClaw plugin for document processing via Nutrient DWS API",
55
"license": "MIT",
66
"repository": {
@@ -20,6 +20,10 @@
2020
"test": "vitest run",
2121
"test:watch": "vitest",
2222
"lint": "tsc --noEmit",
23+
"sync:version": "node ./scripts/sync-version.mjs",
24+
"release:check": "npm run lint && npm test",
25+
"preversion": "npm run release:check",
26+
"version": "npm run sync:version && git add openclaw.plugin.json",
2327
"prepublishOnly": "npm run build && npm run test"
2428
},
2529
"openclaw": {

scripts/sync-version.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
3+
import fs from 'node:fs';
4+
import path from 'node:path';
5+
6+
const root = process.cwd();
7+
const packagePath = path.join(root, 'package.json');
8+
const pluginPath = path.join(root, 'openclaw.plugin.json');
9+
10+
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
11+
const plugin = JSON.parse(fs.readFileSync(pluginPath, 'utf8'));
12+
13+
if (!pkg.version || typeof pkg.version !== 'string') {
14+
throw new Error('package.json version is missing or invalid');
15+
}
16+
17+
if (plugin.version === pkg.version) {
18+
console.log(`openclaw.plugin.json already matches version ${pkg.version}`);
19+
process.exit(0);
20+
}
21+
22+
plugin.version = pkg.version;
23+
fs.writeFileSync(pluginPath, `${JSON.stringify(plugin, null, 2)}\n`);
24+
console.log(`Synced openclaw.plugin.json version -> ${pkg.version}`);

src/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import type { NutrientClient, NutrientResponse } from './types.js';
1212
const API_BASE = 'https://api.nutrient.io';
1313
const CREDIT_USAGE_HEADER = 'x-pspdfkit-credit-usage';
1414
const REMAINING_CREDITS_HEADER = 'x-pspdfkit-remaining-credits';
15+
const USER_AGENT = 'NutrientOpenClawPlugin';
1516

1617
/**
1718
* Create an HTTP client bound to a specific API key.
1819
*
1920
* Every request includes:
2021
* - `Authorization: Bearer <apiKey>`
21-
* - `User-Agent: NutrientOpenClawPlugin/0.1.0`
22+
* - `User-Agent: NutrientOpenClawPlugin`
2223
*
2324
* Credit headers (`x-pspdfkit-credit-usage`, `x-pspdfkit-remaining-credits`)
2425
* are extracted from every response and returned in the `NutrientResponse`.
@@ -33,7 +34,7 @@ export function makeClient(apiKey: string): NutrientClient {
3334
const url = `${API_BASE}/${endpoint}`;
3435
const headers: Record<string, string> = {
3536
Authorization: `Bearer ${apiKey}`,
36-
'User-Agent': 'NutrientOpenClawPlugin/0.1.0',
37+
'User-Agent': USER_AGENT,
3738
};
3839

3940
const isFormData = body instanceof FormData;

test/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('makeClient', () => {
5050
await client.post('build', {});
5151

5252
const call = (globalThis.fetch as ReturnType<typeof vi.fn>).mock.calls[0];
53-
expect(call[1].headers['User-Agent']).toBe('NutrientOpenClawPlugin/0.1.0');
53+
expect(call[1].headers['User-Agent']).toBe('NutrientOpenClawPlugin');
5454
});
5555

5656
it('sends Content-Type: application/json for object bodies', async () => {

0 commit comments

Comments
 (0)