Skip to content

Commit f9d8ddb

Browse files
committed
feat: publish python sdk
1 parent cf79704 commit f9d8ddb

16 files changed

Lines changed: 639 additions & 95 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ jobs:
3939
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
4040

4141
- name: Publish
42-
run: pnpm -r --filter "./sdk/**" publish --access public --no-git-checks
42+
run: |
43+
pnpm -r --filter "./sdk/**" publish --access public --no-git-checks
44+
pnpm publish:python
4345
env:
4446
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4547
NPM_CONFIG_PROVENANCE: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ target
77
service/uni-token-service
88
frontend/public/release
99
.eslintcache
10-
sdk/node/README.md
1110
docs/.vitepress/cache
1211
.fuse_hidden*
1312
sdk/go/example/uni-token-example
13+
14+
sdk/*/README.md

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"[yaml]": {
7070
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
7171
},
72+
"[toml]": {
73+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
74+
},
7275
"i18n-ally.enabledFrameworks": [
7376
"vue"
7477
],

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
### Preparation
1717

1818
```sh
19-
pnpm -C frontend i
19+
pnpm i
2020
go -C service mod tidy
2121
uv --directory sdk/python sync
2222
```
@@ -25,6 +25,7 @@ uv --directory sdk/python sync
2525

2626
```sh
2727
pnpm -C frontend dev
28+
pnpm -C docs dev
2829
go -C service run main.go
2930
uv --directory sdk/python run example.py
3031
```
@@ -33,6 +34,7 @@ uv --directory sdk/python run example.py
3334

3435
```sh
3536
pnpm -C frontend build
37+
pnpm -C docs build
3638
go -C service build
3739
```
3840

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: home
33

44
hero:
55
name: UniToken
6-
text: Token Solution for Local AI Agents
6+
text: LLM Token Solution for Local AI Agents
77
tagline: Open-source, local-first, and lightweight.
88
image:
99
light: /logo-light.png

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"name": "@uni-token/monorepo",
3+
"type": "module",
34
"version": "1.0.0",
45
"private": true,
56
"packageManager": "pnpm@10.13.1",
67
"license": "MIT",
78
"scripts": {
89
"lint": "eslint --cache",
9-
"build": "node --experimental-strip-types scripts/build.mts"
10+
"build": "node --experimental-strip-types scripts/build.ts",
11+
"publish:python": "node --experimental-strip-types scripts/publish.ts"
1012
},
1113
"devDependencies": {
1214
"@antfu/eslint-config": "^5.2.1",
File renamed without changes.

scripts/publish.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { readFileSync, writeFileSync } from 'node:fs'
2+
import { resolve } from 'node:path'
3+
import { $ } from 'zx'
4+
5+
async function publishPythonSdk() {
6+
const readme = readFileSync(resolve(import.meta.dirname, '../README.md'), 'utf8')
7+
const trimmed = readme.replace(/\n<!--DEV-->([\s\S]*?)<!--\/DEV-->\n/g, '')
8+
writeFileSync(resolve(import.meta.dirname, '../sdk/python/README.md'), trimmed)
9+
10+
console.log('Building package...')
11+
12+
$.cwd = resolve(import.meta.dirname, '../sdk/python')
13+
14+
await $`rm -rf dist/ build/ *.egg-info/`
15+
16+
await $`uvx --from build pyproject-build --installer uv`
17+
18+
await $`uvx twine check dist/*`
19+
20+
console.log(`Publishing to pypi...`)
21+
22+
await $`uvx twine upload dist/*`
23+
console.log('Package published to PyPI successfully!')
24+
}
25+
26+
publishPythonSdk()

sdk/node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"dist"
1414
],
1515
"scripts": {
16+
"prepublishOnly": "pnpm build",
1617
"build": "tsdown",
1718
"test": "node --experimental-strip-types ./src/example.ts"
1819
},

sdk/python/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from lib import request_unitoken_openai
1+
from unitoken import request_unitoken_openai
22
from openai import OpenAI
33

44

0 commit comments

Comments
 (0)