Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
# Check version synchronization
version-check:
name: Version Sync Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Check version sync
run: python scripts/sync-versions.py --check

# Check feature parity
feature-parity:
name: Feature Parity Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Check feature parity
run: python scripts/check-feature-parity.py

# TypeScript CI
typescript:
name: TypeScript
runs-on: ubuntu-latest
defaults:
run:
working-directory: ts
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: ts/package-lock.json

- name: Install dependencies
run: npm ci

- name: Type check
run: npm run typecheck

- name: Build
run: npm run build

- name: Run tests
run: npm test

# Python CI
python:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Lint with ruff
run: ruff check .

- name: Type check with mypy
run: mypy capture_sdk --ignore-missing-imports

- name: Run tests
run: pytest -v

# All checks passed
ci-success:
name: CI Success
needs: [version-check, feature-parity, typescript, python]
runs-on: ubuntu-latest
steps:
- name: All checks passed
run: echo "All CI checks passed!"
143 changes: 143 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
# Validate release
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"

- name: Verify version sync
run: python scripts/sync-versions.py --check

- name: Verify tag matches package versions
run: |
VERSION=${{ steps.version.outputs.version }}
TS_VERSION=$(node -p "require('./ts/package.json').version")
PY_VERSION=$(grep -Po '(?<=^version = ")[^"]+' python/pyproject.toml)

if [ "$VERSION" != "$TS_VERSION" ]; then
echo "Tag version ($VERSION) does not match TypeScript version ($TS_VERSION)"
exit 1
fi

if [ "$VERSION" != "$PY_VERSION" ]; then
echo "Tag version ($VERSION) does not match Python version ($PY_VERSION)"
exit 1
fi

echo "Version $VERSION verified in both SDKs"

# Publish TypeScript to npm
publish-npm:
name: Publish to npm
needs: validate
runs-on: ubuntu-latest
defaults:
run:
working-directory: ts
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: "npm"
cache-dependency-path: ts/package-lock.json

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Publish Python to PyPI
publish-pypi:
name: Publish to PyPI
needs: validate
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*

# Create GitHub Release
github-release:
name: Create GitHub Release
needs: [validate, publish-npm, publish-pypi]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ needs.validate.outputs.version }}
body: |
## Capture SDK v${{ needs.validate.outputs.version }}

### Installation

**TypeScript/JavaScript:**
```bash
npm install @numbersprotocol/capture-sdk@${{ needs.validate.outputs.version }}
```

**Python:**
```bash
pip install capture-sdk==${{ needs.validate.outputs.version }}
```

### Links
- [npm package](https://www.npmjs.com/package/@numbersprotocol/capture-sdk)
- [PyPI package](https://pypi.org/project/capture-sdk/)
generate_release_notes: true
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules/

# Build output
dist/
build/

# IDE
.idea/
Expand All @@ -25,7 +26,27 @@ npm-debug.log*

# Test coverage
coverage/
htmlcov/
.coverage

# Temporary files
*.tmp
*.temp

# TypeScript
ts/dist/

# Python
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
*.egg
.eggs/
python/dist/
python/build/
.pytest_cache/
.mypy_cache/
.ruff_cache/
venv/
.venv/
Loading
Loading