Skip to content

Commit 45892ec

Browse files
committed
Reorganize SDKs and add Python SDK
- Move JavaScript SDK from /sdk to /sdk/javascript - Add Python SDK at /sdk/python with full feature parity - Update build.yml workflow to use correct SDK path - Add PyPI trusted publishing workflow for Python SDK - Both SDKs now at version 0.5.0
1 parent bb6310d commit 45892ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3566
-24
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,21 @@ jobs:
390390

391391
- name: Install dependencies and build
392392
if: steps.sdk-changes.outputs.changed == 'true'
393-
working-directory: sdk
393+
working-directory: sdk/javascript
394394
run: |
395395
npm ci
396396
npm run build
397397
398398
- name: Update package version
399399
if: steps.sdk-changes.outputs.changed == 'true'
400-
working-directory: sdk
400+
working-directory: sdk/javascript
401401
run: |
402402
VERSION="${GITHUB_REF_NAME#v}"
403403
npm version "$VERSION" --no-git-tag-version --allow-same-version
404404
405405
- name: Publish to GitHub Packages
406406
if: steps.sdk-changes.outputs.changed == 'true'
407-
working-directory: sdk
407+
working-directory: sdk/javascript
408408
run: |
409409
npm publish 2>&1 | tee publish.log || {
410410
if grep -q "Cannot publish over existing version" publish.log; then

.github/workflows/sdk-ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: SDK CI
1+
name: JavaScript SDK CI
22

33
on:
44
pull_request:
55
paths:
6-
- 'sdk/**'
6+
- 'sdk/javascript/**'
77
push:
88
paths:
9-
- 'sdk/**'
9+
- 'sdk/javascript/**'
1010
branches-ignore:
1111
- main
1212

@@ -26,17 +26,17 @@ jobs:
2626
node-version: ${{ matrix.node-version }}
2727

2828
- name: Install dependencies
29-
working-directory: ./sdk
29+
working-directory: ./sdk/javascript
3030
run: npm ci
3131

3232
- name: Type check
33-
working-directory: ./sdk
33+
working-directory: ./sdk/javascript
3434
run: npm run typecheck
3535

3636
- name: Run tests
37-
working-directory: ./sdk
37+
working-directory: ./sdk/javascript
3838
run: npm test
3939

4040
- name: Build
41-
working-directory: ./sdk
41+
working-directory: ./sdk/javascript
4242
run: npm run build
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Python SDK CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'sdk/python/**'
7+
push:
8+
paths:
9+
- 'sdk/python/**'
10+
branches-ignore:
11+
- main
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
working-directory: ./sdk/python
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -e ".[dev]"
34+
35+
- name: Lint with ruff
36+
working-directory: ./sdk/python
37+
run: ruff check src tests
38+
39+
- name: Type check with mypy
40+
working-directory: ./sdk/python
41+
run: mypy src
42+
43+
- name: Run tests
44+
working-directory: ./sdk/python
45+
run: pytest --cov=src/nfc_agent --cov-report=xml
46+
47+
- name: Upload coverage
48+
if: matrix.python-version == '3.12'
49+
uses: codecov/codecov-action@v4
50+
with:
51+
files: ./sdk/python/coverage.xml
52+
flags: python-sdk
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release Python SDK
2+
3+
on:
4+
push:
5+
paths:
6+
- 'sdk/python/**'
7+
branches:
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
working-directory: ./sdk/python
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e ".[dev]"
27+
28+
- name: Lint
29+
working-directory: ./sdk/python
30+
run: ruff check src tests
31+
32+
- name: Type check
33+
working-directory: ./sdk/python
34+
run: mypy src
35+
36+
- name: Run tests
37+
working-directory: ./sdk/python
38+
run: pytest
39+
40+
release:
41+
runs-on: ubuntu-latest
42+
needs: test
43+
permissions:
44+
id-token: write # Required for PyPI trusted publishing
45+
contents: write # Required for creating GitHub releases
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 2
51+
52+
- name: Check if version changed
53+
id: version-check
54+
working-directory: ./sdk/python
55+
run: |
56+
# Get current version from pyproject.toml
57+
CURRENT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
58+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
59+
60+
# Get previous version (if exists)
61+
git show HEAD~1:sdk/python/pyproject.toml > /tmp/prev-pyproject.toml 2>/dev/null || echo '[project]\nversion = "0.0.0"' > /tmp/prev-pyproject.toml
62+
PREV_VERSION=$(python -c "import tomllib; print(tomllib.load(open('/tmp/prev-pyproject.toml', 'rb')).get('project', {}).get('version', '0.0.0'))" 2>/dev/null || echo "0.0.0")
63+
echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUT
64+
65+
# Check if versions differ
66+
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
67+
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
68+
echo "changed=true" >> $GITHUB_OUTPUT
69+
else
70+
echo "Version unchanged ($CURRENT_VERSION)"
71+
echo "changed=false" >> $GITHUB_OUTPUT
72+
fi
73+
74+
- name: Set up Python
75+
if: steps.version-check.outputs.changed == 'true'
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: '3.12'
79+
80+
- name: Install build tools
81+
if: steps.version-check.outputs.changed == 'true'
82+
run: pip install build
83+
84+
- name: Build package
85+
if: steps.version-check.outputs.changed == 'true'
86+
working-directory: ./sdk/python
87+
run: python -m build
88+
89+
- name: Publish to PyPI
90+
if: steps.version-check.outputs.changed == 'true'
91+
uses: pypa/gh-action-pypi-publish@release/v1
92+
with:
93+
packages-dir: sdk/python/dist/
94+
95+
- name: Create GitHub Release
96+
if: steps.version-check.outputs.changed == 'true'
97+
uses: softprops/action-gh-release@v2
98+
with:
99+
tag_name: python-sdk-v${{ steps.version-check.outputs.current_version }}
100+
name: Python SDK v${{ steps.version-check.outputs.current_version }}
101+
body: |
102+
## nfc-agent (Python) v${{ steps.version-check.outputs.current_version }}
103+
104+
Install via pip:
105+
```bash
106+
pip install nfc-agent==${{ steps.version-check.outputs.current_version }}
107+
```
108+
generate_release_notes: true

.github/workflows/sdk-release.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Release SDK
1+
name: Release JavaScript SDK
22

33
on:
44
push:
55
paths:
6-
- 'sdk/**'
6+
- 'sdk/javascript/**'
77
branches:
88
- main
99

@@ -20,19 +20,19 @@ jobs:
2020
node-version: '20'
2121

2222
- name: Install dependencies
23-
working-directory: ./sdk
23+
working-directory: ./sdk/javascript
2424
run: npm ci
2525

2626
- name: Type check
27-
working-directory: ./sdk
27+
working-directory: ./sdk/javascript
2828
run: npm run typecheck
2929

3030
- name: Run tests
31-
working-directory: ./sdk
31+
working-directory: ./sdk/javascript
3232
run: npm test
3333

3434
- name: Build
35-
working-directory: ./sdk
35+
working-directory: ./sdk/javascript
3636
run: npm run build
3737

3838
release:
@@ -46,14 +46,14 @@ jobs:
4646

4747
- name: Check if version changed
4848
id: version-check
49-
working-directory: ./sdk
49+
working-directory: ./sdk/javascript
5050
run: |
5151
# Get current version
5252
CURRENT_VERSION=$(node -p "require('./package.json').version")
5353
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
5454
5555
# Get previous version (if exists)
56-
git show HEAD~1:sdk/package.json > /tmp/prev-package.json 2>/dev/null || echo '{"version":"0.0.0"}' > /tmp/prev-package.json
56+
git show HEAD~1:sdk/javascript/package.json > /tmp/prev-package.json 2>/dev/null || echo '{"version":"0.0.0"}' > /tmp/prev-package.json
5757
PREV_VERSION=$(node -p "require('/tmp/prev-package.json').version")
5858
echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUT
5959
@@ -75,17 +75,17 @@ jobs:
7575

7676
- name: Install dependencies
7777
if: steps.version-check.outputs.changed == 'true'
78-
working-directory: ./sdk
78+
working-directory: ./sdk/javascript
7979
run: npm ci
8080

8181
- name: Build
8282
if: steps.version-check.outputs.changed == 'true'
83-
working-directory: ./sdk
83+
working-directory: ./sdk/javascript
8484
run: npm run build
8585

8686
- name: Publish to NPM
8787
if: steps.version-check.outputs.changed == 'true'
88-
working-directory: ./sdk
88+
working-directory: ./sdk/javascript
8989
run: |
9090
if [ -z "$NODE_AUTH_TOKEN" ]; then
9191
echo "NPM_TOKEN not configured - skipping publish"
@@ -99,8 +99,8 @@ jobs:
9999
if: steps.version-check.outputs.changed == 'true'
100100
uses: softprops/action-gh-release@v2
101101
with:
102-
tag_name: sdk-v${{ steps.version-check.outputs.current_version }}
103-
name: SDK v${{ steps.version-check.outputs.current_version }}
102+
tag_name: js-sdk-v${{ steps.version-check.outputs.current_version }}
103+
name: JavaScript SDK v${{ steps.version-check.outputs.current_version }}
104104
body: |
105105
## @simplyprint/nfc-agent v${{ steps.version-check.outputs.current_version }}
106106
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)