From cc343e0a4708b671fe5adfa09e669fb5ec2ce38d Mon Sep 17 00:00:00 2001 From: Julian Schoen Date: Wed, 1 Apr 2026 22:26:48 +0200 Subject: [PATCH] feat: add npm publishing workflow and build configuration Add tsconfig.build.json for each package to emit JS + declarations to dist/, configure package.json with exports, files, and publishConfig, and create a GitHub Actions workflow triggered by version tags. --- .github/workflows/publish.yml | 51 ++++++++++++++++++++++++++++ package.json | 2 ++ packages/cli/package.json | 43 +++++++++++++++++++++-- packages/cli/tsconfig.build.json | 14 ++++++++ packages/core/package.json | 40 ++++++++++++++++++++-- packages/core/tsconfig.build.json | 14 ++++++++ packages/sandbox/package.json | 39 +++++++++++++++++++-- packages/sandbox/tsconfig.build.json | 14 ++++++++ 8 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 packages/cli/tsconfig.build.json create mode 100644 packages/core/tsconfig.build.json create mode 100644 packages/sandbox/tsconfig.build.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ac37ede --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,51 @@ +name: Publish to npm + +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: '20' + registry-url: 'https://registry.npmjs.org' + + - run: bun install + + # Type-check + - run: bun run build + + # Run tests + - run: bun run --filter 'open-browser' test + + # Build JS output for publishing + - run: bun run --filter 'open-browser' build:publish + - run: bun run --filter '@open-browser/cli' build:publish + - run: bun run --filter '@open-browser/sandbox' build:publish + + # Publish packages in dependency order + - name: Publish open-browser (core) + run: npm publish --workspace=packages/core --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish @open-browser/sandbox + run: npm publish --workspace=packages/sandbox --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish @open-browser/cli + run: npm publish --workspace=packages/cli --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 229e31b..8f13bf7 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "workspaces": ["packages/*"], "scripts": { "build": "bun run --filter '*' build", + "build:publish": "bun run --filter '*' build:publish", + "clean": "bun run --filter '*' clean", "test": "bun run --filter '*' test", "lint": "biome check .", "format": "biome format --write ." diff --git a/packages/cli/package.json b/packages/cli/package.json index 4f3404a..aeaecf8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -5,17 +5,54 @@ "type": "module", "main": "src/index.ts", "bin": { - "open-browser": "src/index.ts" + "open-browser": "dist/index.js" }, + "exports": { + ".": { + "bun": "./src/index.ts", + "types": "./src/index.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, + "files": [ + "dist", + "src", + "LICENSE", + "README.md" + ], "scripts": { "build": "tsc --noEmit", + "build:publish": "tsc -p tsconfig.build.json", + "clean": "rm -rf dist *.tsbuildinfo", + "prepublishOnly": "bun run clean && bun run build:publish", "test": "bun test", "start": "bun run src/index.ts" }, + "publishConfig": { + "access": "public" + }, + "keywords": [ + "browser", + "automation", + "ai", + "cli", + "agent" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/ntegrals/openbrowser.git", + "directory": "packages/cli" + }, + "homepage": "https://github.com/ntegrals/openbrowser#readme", + "bugs": { + "url": "https://github.com/ntegrals/openbrowser/issues" + }, + "author": "ntegrals", + "license": "MIT", "dependencies": { "open-browser": "workspace:*", "commander": "^12.1.0", "chalk": "^5.4.0" - }, - "license": "MIT" + } } diff --git a/packages/cli/tsconfig.build.json b/packages/cli/tsconfig.build.json new file mode 100644 index 0000000..e19f976 --- /dev/null +++ b/packages/cli/tsconfig.build.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "noEmit": false, + "allowImportingTsExtensions": false, + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/packages/core/package.json b/packages/core/package.json index 91b4f82..af1987a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -6,13 +6,48 @@ "main": "src/index.ts", "types": "src/index.ts", "exports": { - ".": "./src/index.ts" + ".": { + "bun": "./src/index.ts", + "types": "./src/index.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } }, + "files": [ + "dist", + "src", + "LICENSE", + "README.md" + ], "scripts": { "build": "tsc --noEmit", + "build:publish": "tsc -p tsconfig.build.json", + "clean": "rm -rf dist *.tsbuildinfo", + "prepublishOnly": "bun run clean && bun run build:publish", "test": "bun test", "lint": "biome check src/" }, + "keywords": [ + "browser", + "automation", + "ai", + "agent", + "web", + "scraping", + "playwright", + "llm" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/ntegrals/openbrowser.git", + "directory": "packages/core" + }, + "homepage": "https://github.com/ntegrals/openbrowser#readme", + "bugs": { + "url": "https://github.com/ntegrals/openbrowser/issues" + }, + "author": "ntegrals", + "license": "MIT", "dependencies": { "ai": "^4.2.0", "@ai-sdk/openai": "^1.1.0", @@ -35,6 +70,5 @@ "sharp": { "optional": true } - }, - "license": "MIT" + } } diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json new file mode 100644 index 0000000..e19f976 --- /dev/null +++ b/packages/core/tsconfig.build.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "noEmit": false, + "allowImportingTsExtensions": false, + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/packages/sandbox/package.json b/packages/sandbox/package.json index c528d45..50921ce 100644 --- a/packages/sandbox/package.json +++ b/packages/sandbox/package.json @@ -6,14 +6,47 @@ "main": "src/index.ts", "types": "src/index.ts", "exports": { - ".": "./src/index.ts" + ".": { + "bun": "./src/index.ts", + "types": "./src/index.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } }, + "files": [ + "dist", + "src", + "LICENSE", + "README.md" + ], "scripts": { "build": "tsc --noEmit", + "build:publish": "tsc -p tsconfig.build.json", + "clean": "rm -rf dist *.tsbuildinfo", + "prepublishOnly": "bun run clean && bun run build:publish", "test": "bun test" }, + "publishConfig": { + "access": "public" + }, + "keywords": [ + "browser", + "automation", + "sandbox", + "agent" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/ntegrals/openbrowser.git", + "directory": "packages/sandbox" + }, + "homepage": "https://github.com/ntegrals/openbrowser#readme", + "bugs": { + "url": "https://github.com/ntegrals/openbrowser/issues" + }, + "author": "ntegrals", + "license": "MIT", "dependencies": { "open-browser": "workspace:*" - }, - "license": "MIT" + } } diff --git a/packages/sandbox/tsconfig.build.json b/packages/sandbox/tsconfig.build.json new file mode 100644 index 0000000..e19f976 --- /dev/null +++ b/packages/sandbox/tsconfig.build.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "noEmit": false, + "allowImportingTsExtensions": false, + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.test.ts"] +}