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
82 changes: 82 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Changesets Workflow

This project uses [Changesets](https://github.com/changesets/changesets) for version management and changelog generation.

## Quick Start

```bash
# Install changesets globally (one-time)
npm install -g @changesets/cli

# Or use npx
npx changeset
```

## Creating a Changeset

When you make changes that should be released:

```bash
# From the monorepo root
npx changeset
```

This will prompt you:
1. **Select packages** - Choose `@crewcircle/knowledge` (or other packages)
2. **Select semver bump** - `patch` (bugfix), `minor` (feature), `major` (breaking)
3. **Write summary** - Brief description for the changelog

A markdown file will be created in `.changeset/` with a random name like `tidy-cats-play.md`.

## Versioning & Publishing

### Automated (via GitHub Actions)

1. Merge changes to `main`
2. GitHub Action detects changesets
3. Creates a "Version Packages" PR with version bumps + changelog
4. Merge the Version PR
5. GitHub Action publishes to npm on tag push

### Manual (if needed)

```bash
# Version packages (updates package.json, creates CHANGELOG.md)
npx changeset version

# Build packages
npm run build --workspace=@crewcircle/knowledge

# Publish to npm (requires NPM_TOKEN)
npx changeset publish
```

## Semver Guidelines

| Change Type | Bump | Example |
|-------------|------|---------|
| Bug fix | `patch` | Fix embedding dimension mismatch |
| New feature | `minor` | Add new provider type |
| Breaking change | `major` | Remove deprecated API |

## Release Tags

Tags follow the format: `knowledge-v{version}` (e.g., `knowledge-v1.2.3`)

This allows independent versioning if we add more packages later.

## GitHub Actions

Two workflows handle the pipeline:

| Workflow | Trigger | Purpose |
|----------|---------|---------|
| `.github/workflows/ci.yml` | PR/push | Lint, typecheck, test, build |
| `.github/workflows/release.yml` | Changeset merged / tag pushed | Version + publish to npm |

## Adding a New Package

1. Add package to `packages/`
2. Add to `publishConfig` in package.json
3. Update `.changeset/config.json` if needed
4. Run `npx changeset` to create initial changeset
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
137 changes: 137 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: CI

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

jobs:
typecheck:
name: TypeCheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: TypeCheck
run: npm run typecheck --workspace=@crewcircle/knowledge

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint --workspace=@crewcircle/knowledge

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: Run Tests
run: npm test --workspace=@crewcircle/knowledge

build:
name: Build
runs-on: ubuntu-latest
needs: [typecheck, lint, test]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build --workspace=@crewcircle/knowledge

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: packages/knowledge/dist
retention-days: 7

changeset:
name: Changeset
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install changesets
run: npm install -g @changesets/cli

- name: Check for changesets
id: changesets
run: |
if npx changeset status --since=main; then
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi

- name: Comment PR
if: steps.changesets.outputs.has_changesets == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ This PR has a changeset. Version bump will be applied on merge.'
})
111 changes: 111 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Release

on:
push:
branches: [main]
tags:
- 'knowledge-v*'
workflow_dispatch:

permissions:
contents: write
packages: write
pull-requests: write
issues: write
id-token: write

jobs:
version:
name: Version Packages
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
has_changesets: ${{ steps.changesets.outputs.has_changesets }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Install changesets
run: npm install -g @changesets/cli

- name: Check for changesets
id: changesets
run: |
if npx changeset status --since=main >/dev/null 2>&1; then
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi

- name: Version packages
if: steps.changesets.outputs.has_changesets == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
npx changeset version
git add -A
git commit -m "chore: version packages [skip ci]" || true
git push

- name: Create Release PR
if: steps.changesets.outputs.has_changesets == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: changeset-release
title: 'chore: version packages'
body: |
This PR was created automatically by the release workflow.
It contains version bumps and changelog updates from merged changesets.
labels: |
release
automated
draft: false

publish:
name: Publish to npm
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/knowledge-v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build knowledge package
run: npm run build --workspace=@crewcircle/knowledge

- name: Verify package
run: |
cd packages/knowledge/dist
npm pack --dry-run

- name: Publish to npm
run: npm publish packages/knowledge/dist --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading
Loading