# Bin Directory

This directory contains utility and deployment scripts for PyCharter.

## Scripts

### `seed`

Seeds the database with `data/seed` YAMLs (owners, domains, systems, etc.), then loads aviation example contracts from `data/aviation_examples` into the metadata store.

**Requirements:** Run `pycharter db init` (or use an existing DB) before the first run.

**Usage:**

```bash
# From project root (pycharter/)
python bin/seed

# Custom database URL
python bin/seed --database-url sqlite:///pycharter.db

# Only seed data/seed (skip aviation examples)
python bin/seed --skip-aviation
```

**Behavior:**

1. Seeds `data/seed` (same as `pycharter db seed`).
2. Discovers all `*_contract.yaml` under `data/aviation_examples`, parses each, and stores schema, coercion rules, validation rules, and metadata in the metadata store. Contracts that already exist (same title/version) are skipped.

### `release.sh`

Automated release script that handles the complete release workflow:

1. ✅ Updates version in `pyproject.toml` and `pycharter/__init__.py`
2. ✅ Commits changes
3. ✅ Pushes to remote
4. ✅ Creates and pushes git tag
5. ✅ Creates GitHub release (optional)

#### Usage

```bash
# Basic usage (will prompt for version)
./bin/release.sh

# Specify version
./bin/release.sh 0.0.21

# Dry run (see what would happen without making changes)
./bin/release.sh 0.0.21 --dry-run

# Skip GitHub release creation (just tag)
./bin/release.sh 0.0.21 --no-release
```

#### Features

- ✅ Validates version format (semantic versioning: x.y.z)
- ✅ Checks for uncommitted changes
- ✅ Verifies you're on main/master branch
- ✅ Prevents duplicate tags
- ✅ Dry-run mode for testing
- ✅ Interactive confirmations
- ✅ Color-coded output
- ✅ Error handling

#### Examples

```bash
# Release version 0.0.21
./bin/release.sh 0.0.21

# Test the release process without making changes
./bin/release.sh 0.0.21 --dry-run

# Create tag only (no GitHub release)
./bin/release.sh 0.0.21 --no-release
```

#### What It Does

1. **Reads current version** from `pyproject.toml`
2. **Updates version** in:
   - `pyproject.toml`
   - `pycharter/__init__.py` (if exists)
3. **Git operations**:
   - `git add` (stages version files)
   - `git commit -m "Bump version to X.X.X"`
   - `git push`
   - `git tag -a vX.X.X -m "Release vX.X.X"`
   - `git push origin vX.X.X`
4. **GitHub release** (if `gh` CLI is installed):
   - `gh release create vX.X.X --title "vX.X.X" --notes "..."`

#### Requirements

- Git
- GitHub CLI (`gh`) - optional, for automatic release creation
- Bash 4.0+

#### Safety Features

- ✅ Checks for uncommitted changes
- ✅ Validates version format
- ✅ Prevents duplicate tags
- ✅ Confirms before proceeding
- ✅ Dry-run mode available
