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
4 changes: 4 additions & 0 deletions .github/workflows/mirror-packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Mirror Packages to Repositories

# This workflow mirrors packages from the monorepo packages/ directory to individual repositories.
# Only packages in packages/ directory are mirrored (plugins and distributable packages).
# Internal libraries in libs/ directory are not mirrored.

on:
push:
tags:
Expand Down
161 changes: 67 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,34 @@ This repository is the **single source of truth** for all [OpenCode](https://ope
This is an NX monorepo with Bun + TypeScript that:

- Develops multiple OpenCode plugins under `packages/`
- Provides a shared documentation builder in `apps/docs-builder/`
- Mirrors each plugin to dedicated read-only GitHub repos for distribution
- Mirrors the docs-builder to a separate read-only repo
- Publishes each plugin independently to npm under `@pantheon-org/<plugin-name>`
- Deploys plugin documentation to GitHub Pages per plugin using the shared docs-builder
- Provides internal shared libraries under `libs/`
- Mirrors each plugin and distributable package to dedicated read-only GitHub repos
- Publishes plugins and packages independently to npm under `@pantheon-org/<name>`
- Deploys plugin documentation to GitHub Pages per plugin

## Directory Structure

### `packages/` - Mirrored Distributable Packages

All packages under `packages/` are:

- **Mirrored** to individual GitHub repositories
- **Published** to npm as `@pantheon-org/<name>`
- **Tagged** using format `<name>@v<version>` (e.g., `opencode-font@v1.0.0`)

**Types of packages:**

- **OpenCode Plugins**: Extend OpenCode functionality (prefixed with `opencode-`)
- **Distributable Packages**: Standalone npm packages (e.g., `opencode-font`)

### `libs/` - Internal Libraries (Not Mirrored)

Internal libraries for monorepo support:

- **workflows/** - CI/CD automation scripts and utilities
- **docs-builder/** - Shared Astro documentation builder

These are **not mirrored** or published to npm.

### Plugins

Expand All @@ -31,21 +54,20 @@ Each plugin:

The shared documentation builder:

- Lives in `apps/docs-builder/`
- Is mirrored to: `pantheon-org/opencode-docs-builder` (read-only)
- Lives in `libs/docs-builder/`
- Contains Astro + Starlight configuration
- Is pulled by plugin mirror repos during GitHub Pages deployment
- Has independent versioning (tagged as `docs-builder@v1.0.0`)
- Used internally, not distributed

### Workflows App
### Workflows

The workflows app contains automated CI/CD scripts and utilities:
The workflows library contains automated CI/CD scripts and utilities:

- Lives in `apps/workflows/`
- Lives in `libs/workflows/`
- Built with Bun + TypeScript (strict mode)
- Modular architecture with comprehensive test coverage
- Used by GitHub Actions workflows for repository automation
- See [Workflows App Documentation](apps/workflows/README.md) for details
- See [Workflows Documentation](libs/workflows/README.md) for details

## Quick Start

Expand Down Expand Up @@ -103,7 +125,17 @@ All development happens in this monorepo. Mirror repos are read-only distributio

```
opencode-plugins/
├── apps/
├── packages/ # Mirrored distributable packages
│ ├── opencode-warcraft-notification/ # Example plugin (reference template)
│ │ ├── docs/ # Plugin-specific markdown docs
│ │ ├── src/ # Plugin TypeScript source
│ │ └── package.json # Plugin dependencies
│ ├── opencode-font/ # Font package (non-plugin)
│ │ ├── src/ # Font generation source
│ │ ├── css/ # Generated CSS
│ │ └── fonts/ # Generated font files
│ └── <other-plugins>/ # Future plugins follow same structure
├── libs/ # Internal libraries (not mirrored)
│ ├── docs-builder/ # Shared Astro documentation builder
│ │ ├── src/ # Astro components, styles
│ │ ├── astro.config.mjs # Astro configuration
Expand All @@ -114,52 +146,43 @@ opencode-plugins/
│ │ ├── scripts/ # Workflow scripts
│ │ └── utils/ # Shared utilities
│ └── README.md # Workflows documentation
├── packages/
│ ├── opencode-warcraft-notification/ # Example plugin (reference template)
│ │ ├── docs/ # Plugin-specific markdown docs
│ │ ├── src/ # Plugin TypeScript source
│ │ └── package.json # Plugin dependencies (no Astro)
│ └── <other-plugins>/ # Future plugins follow same structure
├── .github/
│ └── workflows/
│ ├── mirror-packages.yml # Mirror plugins to separate repos
│ └── mirror-docs-builder.yml # Mirror docs-builder to separate repo
│ └── mirror-packages.yml # Mirror packages to separate repos
├── nx.json # NX workspace config
├── workspace.json # NX project definitions
└── package.json # Root workspace config
```

## Release Process

### Plugin Releases
### Plugin & Package Releases

All packages in `packages/` directory (plugins and distributable packages) follow the same release process:

```bash
# Tag a plugin release (use plugin-specific tag format)
git tag <plugin-name>@v1.0.0
git push origin <plugin-name>@v1.0.0
# Tag a package release (use package-specific tag format)
git tag <package-name>@v1.0.0
git push origin <package-name>@v1.0.0

# This triggers:
# 1. Dynamic workflow detects the package from tag
# 2. Validates package.json has repository URL
# 3. Checks if package has changes since last tag
# 4. If changes exist: extracts packages/<plugin>/ and pushes to mirror repo
# 5. Adds CI/CD workflows (publish-npm.yml, deploy-docs.yml) to mirror repo
# 6. Mirror repo automatically publishes to npm on tag push
# 7. Mirror repo automatically deploys docs to GitHub Pages
# 4. If changes exist: extracts packages/<package>/ and pushes to mirror repo
# 5. Mirror repo publishes to npm + deploys docs (for plugins)
```

### Docs Builder Releases
### Examples

```bash
# Tag a docs-builder release (use docs-builder tag format)
git tag docs-builder@v1.0.0
git push origin docs-builder@v1.0.0
# Release a plugin
git tag opencode-warcraft-notification@v1.0.0
git push origin opencode-warcraft-notification@v1.0.0

# This triggers:
# 1. Workflow detects docs-builder tag
# 2. Checks for changes in apps/docs-builder/
# 3. If changes exist: extracts apps/docs-builder/ and pushes to mirror repo
# 4. Plugins automatically pull the latest docs-builder during their deployment
# Release a non-plugin package
git tag opencode-font@v1.0.0
git push origin opencode-font@v1.0.0
```

### Mirror Workflow Features
Expand All @@ -171,71 +194,21 @@ The `mirror-packages.yml` workflow automatically:
- **Detects changes** by comparing with previous version tag
- **Skips mirroring** if no changes detected (saves CI time)
- **Extracts subtree** using `git subtree split`
- **Adds CI/CD workflows** from `.github/mirror-templates/` to enable npm publishing and docs deployment
- **Pushes to mirror** repository's `main` branch and creates version tag (uses `--force-with-lease` for safety)
- **Enables GitHub Pages** automatically via API with `workflow` build type
- **Disables repository features** (Issues, Projects, Wiki) to prevent content creation in mirror repos
- **Sets branch protection** to make mirror repository read-only (prevents accidental direct commits)

### Mirror Repository Automation

Each mirror repository automatically receives two GitHub Actions workflows:

1. **`publish-npm.yml`** - Publishes package to npm when tags are pushed
- Runs on `main` branch pushes (dry-run) and `v*` tags (actual publish)
- Executes tests and type checking before publishing
- Uses npm provenance for supply chain security
- Requires `NPM_TOKEN` secret in mirror repo

2. **`deploy-docs.yml`** - Deploys documentation to GitHub Pages
- Clones the shared `opencode-docs-builder` repository
- Copies plugin docs and README into docs-builder structure
- Generates custom Astro config with plugin-specific metadata
- Builds and deploys to GitHub Pages
- Accessible at: `https://pantheon-org.github.io/<plugin-name>/`
- **Pushes to mirror** repository's `main` branch and creates version tag

### Requirements for Mirror Repositories

**For each plugin package:**

1. **Repository URL in package.json:**
**Requirements for each mirrored package:**

1. Package must have `repository.url` in `package.json`:
```json
{
"repository": {
"type": "git",
"url": "git+https://github.com/pantheon-org/<plugin-name>.git"
"url": "git+https://github.com/pantheon-org/<package-name>.git"
}
}
```

2. **Mirror repository must exist** at the URL specified in `repository.url`

3. **GitHub Secrets configured:**
- `MIRROR_REPO_TOKEN` - Personal access token with `repo` scope and `Pages: write` permissions (in monorepo)
- `NPM_TOKEN` - npm automation token with publish access (in mirror repo)

4. **GitHub Pages:** Automatically enabled by mirror workflow with GitHub Actions as build source

5. **Tag format:** `<package-name>@v<version>` (e.g., `opencode-foo-plugin@v1.0.0`)

### Mirror Repository Structure

After mirroring, each repository contains:

```
<plugin-name>/
├── .github/
│ └── workflows/
│ ├── publish-npm.yml # Auto-added by mirror workflow
│ └── deploy-docs.yml # Auto-added by mirror workflow
├── docs/ # Plugin documentation
├── src/ # Plugin source code
├── dist/ # Built output (generated)
├── package.json # Package configuration
├── tsconfig.json # TypeScript config
└── README.md # Main documentation
```
2. Mirror repository must exist and `MIRROR_REPO_TOKEN` must have write access
3. Tag format must be: `<package-name>@v<version>` (e.g., `opencode-font@v1.0.0`)

## Resources

Expand Down
Loading
Loading