Skip to content

Commit fcb468a

Browse files
committed
set up for pkg release
1 parent 3451028 commit fcb468a

4 files changed

Lines changed: 204 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to release (e.g., 0.1.0)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
registry-url: 'https://registry.npmjs.org'
26+
27+
- name: Extract version from tag or input
28+
id: version
29+
run: |
30+
if [ "${{ github.event_name }}" == "release" ]; then
31+
VERSION=${GITHUB_REF#refs/tags/v}
32+
VERSION=${VERSION#refs/tags/}
33+
else
34+
VERSION="${{ github.event.inputs.version }}"
35+
fi
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "Version: $VERSION"
38+
39+
- name: Update version in package.json
40+
run: |
41+
VERSION="${{ steps.version.outputs.version }}"
42+
npm version $VERSION --no-git-tag-version
43+
44+
- name: Install dependencies
45+
run: |
46+
npm ci
47+
48+
- name: Install Playwright browsers
49+
run: |
50+
npx playwright install chromium
51+
52+
- name: Run tests
53+
run: |
54+
npm test
55+
env:
56+
CI: true
57+
58+
- name: Build package
59+
run: |
60+
npm run build
61+
62+
- name: Publish to npm
63+
run: |
64+
npm publish --access public
65+
env:
66+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
67+
68+
- name: Create GitHub Release
69+
if: github.event_name == 'workflow_dispatch'
70+
uses: softprops/action-gh-release@v1
71+
with:
72+
tag_name: v${{ steps.version.outputs.version }}
73+
name: Release v${{ steps.version.outputs.version }}
74+
body: |
75+
Release v${{ steps.version.outputs.version }} of sentience-ts
76+
77+
## Installation
78+
```bash
79+
npm install sentience-ts@${{ steps.version.outputs.version }}
80+
```
81+
draft: false
82+
prerelease: false
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+

.github/workflows/test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
node-version: ['18', '20']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
npm ci
29+
30+
- name: Install Playwright browsers
31+
run: |
32+
npx playwright install chromium
33+
34+
- name: Build extension (if needed)
35+
run: |
36+
if [ -d "../sentience-chrome" ]; then
37+
cd ../sentience-chrome && ./build.sh || echo "Extension build skipped (may not be available in CI)"
38+
else
39+
echo "Extension directory not found, skipping build"
40+
fi
41+
42+
- name: Run tests
43+
run: |
44+
npm test
45+
env:
46+
CI: true
47+

.npmignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Source files
2+
src/
3+
examples/
4+
tests/
5+
*.ts
6+
!*.d.ts
7+
8+
# Build artifacts (keep dist/)
9+
*.map
10+
*.js.map
11+
*.d.ts.map
12+
13+
# Development files
14+
.git/
15+
.github/
16+
node_modules/
17+
*.log
18+
.DS_Store
19+
.env
20+
.env.local
21+
22+
# IDE
23+
.vscode/
24+
.idea/
25+
*.swp
26+
*.swo
27+
28+
# Test files
29+
coverage/
30+
.nyc_output/
31+
jest.config.js
32+
tsconfig.json
33+
34+
# Documentation (keep README.md)
35+
docs/
36+
*.md
37+
!README.md
38+
39+
# CI/CD
40+
.github/
41+
42+
# Temporary files
43+
*.tmp
44+
*.temp
45+

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"scripts": {
88
"build": "tsc",
99
"test": "jest",
10+
"prepare": "npm run build",
11+
"prepublishOnly": "npm test && npm run build",
1012
"example:hello": "ts-node examples/hello.ts",
1113
"example:basic": "ts-node examples/basic-agent.ts",
1214
"cli": "ts-node src/cli.ts"
@@ -25,5 +27,30 @@
2527
"ts-jest": "^29.0.0",
2628
"ts-node": "^10.9.0",
2729
"typescript": "^5.0.0"
30+
},
31+
"files": [
32+
"dist",
33+
"spec",
34+
"README.md",
35+
"LICENSE"
36+
],
37+
"keywords": [
38+
"browser-automation",
39+
"playwright",
40+
"ai-agent",
41+
"web-automation",
42+
"sentience"
43+
],
44+
"repository": {
45+
"type": "git",
46+
"url": "https://github.com/SentienceAPI/sentience-ts.git"
47+
},
48+
"bugs": {
49+
"url": "https://github.com/SentienceAPI/sentience-ts/issues"
50+
},
51+
"homepage": "https://github.com/SentienceAPI/sentience-ts#readme",
52+
"license": "MIT",
53+
"engines": {
54+
"node": ">=18.0.0"
2855
}
2956
}

0 commit comments

Comments
 (0)