Skip to content

Commit a6e67ee

Browse files
authored
feat(sdk): added ts and python SDKs + docs (#524)
* added ts & python sdk, renamed cli from simstudio to cli * added docs * ack PR comments * improvements
1 parent a0c00bc commit a6e67ee

29 files changed

+3581
-15
lines changed

.github/workflows/publish-cli.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- 'packages/simstudio/**'
7+
- 'packages/cli/**'
88

99
jobs:
1010
publish-npm:
@@ -25,16 +25,16 @@ jobs:
2525
registry-url: 'https://registry.npmjs.org/'
2626

2727
- name: Install dependencies
28-
working-directory: packages/simstudio
28+
working-directory: packages/cli
2929
run: bun install
3030

3131
- name: Build package
32-
working-directory: packages/simstudio
32+
working-directory: packages/cli
3333
run: bun run build
3434

3535
- name: Get package version
3636
id: package_version
37-
working-directory: packages/simstudio
37+
working-directory: packages/cli
3838
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
3939

4040
- name: Check if version already exists
@@ -48,7 +48,7 @@ jobs:
4848
4949
- name: Publish to npm
5050
if: steps.version_check.outputs.exists == 'false'
51-
working-directory: packages/simstudio
51+
working-directory: packages/cli
5252
run: npm publish --access=public
5353
env:
5454
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Publish Python SDK
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/python-sdk/**'
8+
9+
jobs:
10+
publish-pypi:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.12'
20+
cache: 'pip'
21+
22+
- name: Install build dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build twine pytest requests tomli
26+
27+
- name: Run tests
28+
working-directory: packages/python-sdk
29+
run: |
30+
PYTHONPATH=. pytest tests/ -v
31+
32+
- name: Get package version
33+
id: package_version
34+
working-directory: packages/python-sdk
35+
run: echo "version=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")" >> $GITHUB_OUTPUT
36+
37+
- name: Check if version already exists
38+
id: version_check
39+
run: |
40+
if pip index versions simstudio-sdk | grep -q "${{ steps.package_version.outputs.version }}"; then
41+
echo "exists=true" >> $GITHUB_OUTPUT
42+
else
43+
echo "exists=false" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Build package
47+
if: steps.version_check.outputs.exists == 'false'
48+
working-directory: packages/python-sdk
49+
run: python -m build
50+
51+
- name: Check package
52+
if: steps.version_check.outputs.exists == 'false'
53+
working-directory: packages/python-sdk
54+
run: twine check dist/*
55+
56+
- name: Publish to PyPI
57+
if: steps.version_check.outputs.exists == 'false'
58+
working-directory: packages/python-sdk
59+
env:
60+
TWINE_USERNAME: __token__
61+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
62+
run: twine upload dist/*
63+
64+
- name: Log skipped publish
65+
if: steps.version_check.outputs.exists == 'true'
66+
run: echo "Skipped publishing because version ${{ steps.package_version.outputs.version }} already exists on PyPI"
67+
68+
- name: Create GitHub Release
69+
if: steps.version_check.outputs.exists == 'false'
70+
uses: softprops/action-gh-release@v1
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: python-sdk-v${{ steps.package_version.outputs.version }}
75+
name: Python SDK v${{ steps.package_version.outputs.version }}
76+
body: |
77+
## Python SDK v${{ steps.package_version.outputs.version }}
78+
79+
Published simstudio-sdk==${{ steps.package_version.outputs.version }} to PyPI.
80+
81+
### Installation
82+
```bash
83+
pip install simstudio-sdk==${{ steps.package_version.outputs.version }}
84+
```
85+
86+
### Documentation
87+
See the [README](https://github.com/simstudio/sim/tree/main/packages/python-sdk) for usage instructions.
88+
draft: false
89+
prerelease: false
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish TypeScript SDK
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/ts-sdk/**'
8+
9+
jobs:
10+
publish-npm:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
21+
- name: Setup Node.js for npm publishing
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18'
25+
registry-url: 'https://registry.npmjs.org/'
26+
27+
- name: Install dependencies
28+
working-directory: packages/ts-sdk
29+
run: bun install
30+
31+
- name: Run tests
32+
working-directory: packages/ts-sdk
33+
run: bun run test
34+
35+
- name: Build package
36+
working-directory: packages/ts-sdk
37+
run: bun run build
38+
39+
- name: Get package version
40+
id: package_version
41+
working-directory: packages/ts-sdk
42+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
43+
44+
- name: Check if version already exists
45+
id: version_check
46+
run: |
47+
if npm view simstudio-ts-sdk@${{ steps.package_version.outputs.version }} version &> /dev/null; then
48+
echo "exists=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "exists=false" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Publish to npm
54+
if: steps.version_check.outputs.exists == 'false'
55+
working-directory: packages/ts-sdk
56+
run: npm publish --access=public
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
60+
- name: Log skipped publish
61+
if: steps.version_check.outputs.exists == 'true'
62+
run: echo "Skipped publishing because version ${{ steps.package_version.outputs.version }} already exists on npm"
63+
64+
- name: Create GitHub Release
65+
if: steps.version_check.outputs.exists == 'false'
66+
uses: softprops/action-gh-release@v1
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
tag_name: typescript-sdk-v${{ steps.package_version.outputs.version }}
71+
name: TypeScript SDK v${{ steps.package_version.outputs.version }}
72+
body: |
73+
## TypeScript SDK v${{ steps.package_version.outputs.version }}
74+
75+
Published simstudio-ts-sdk@${{ steps.package_version.outputs.version }} to npm.
76+
77+
### Installation
78+
```bash
79+
npm install simstudio-ts-sdk@${{ steps.package_version.outputs.version }}
80+
```
81+
82+
### Documentation
83+
See the [README](https://github.com/simstudio/sim/tree/main/packages/ts-sdk) for usage instructions.
84+
draft: false
85+
prerelease: false

apps/docs/content/docs/meta.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"---Execution---",
1313
"execution",
1414
"---Advanced---",
15-
"./variables/index"
15+
"./variables/index",
16+
"---SDKs---",
17+
"./sdks/python",
18+
"./sdks/typescript"
1619
],
1720
"defaultOpen": true
1821
}

0 commit comments

Comments
 (0)