Skip to content

Commit 897299e

Browse files
Merge remote-tracking branch 'origin/main' into kdg/support-model-selection
2 parents 7147ce3 + 25032c6 commit 897299e

3 files changed

Lines changed: 177 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Publish to npm
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: "Version increment type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: patch
15+
16+
permissions:
17+
contents: write
18+
id-token: write
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-latest
23+
environment: npm-publish
24+
concurrency:
25+
group: publish-npm
26+
cancel-in-progress: false
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 22
37+
registry-url: "https://registry.npmjs.org"
38+
cache: npm
39+
40+
- name: Get current npm version
41+
id: current_version
42+
run: |
43+
CURRENT_VERSION=$(npm view @github/copilot-engine-sdk version 2>/dev/null || echo "0.0.0")
44+
echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
45+
echo "Current published version: $CURRENT_VERSION"
46+
echo "- Current published version: \`$CURRENT_VERSION\`" >> "$GITHUB_STEP_SUMMARY"
47+
48+
- name: Calculate next version
49+
id: next_version
50+
run: |
51+
CURRENT="${{ steps.current_version.outputs.version }}"
52+
NEXT_VERSION=$(npx --yes semver "$CURRENT" -i "$VERSION_TYPE")
53+
if [ -z "$NEXT_VERSION" ]; then
54+
echo "Failed to calculate next version from $CURRENT using increment $VERSION_TYPE" >&2
55+
exit 1
56+
fi
57+
echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
58+
echo "Next version: $NEXT_VERSION (incremented $VERSION_TYPE from $CURRENT)"
59+
echo "- Next version: \`$NEXT_VERSION\` (incremented $VERSION_TYPE from \`$CURRENT\`)" >> "$GITHUB_STEP_SUMMARY"
60+
env:
61+
VERSION_TYPE: ${{ inputs.version_type }}
62+
63+
- name: Set package version
64+
env:
65+
VERSION: ${{ steps.next_version.outputs.version }}
66+
run: npm version "$VERSION" --no-git-tag-version
67+
68+
- name: Install dependencies
69+
run: npm ci
70+
71+
- name: Build
72+
run: npm run build
73+
74+
- name: Create npm tarball
75+
run: npm pack
76+
77+
- name: Publish to npm
78+
run: npm publish --access public 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
79+
80+
- name: Determine previous release tag
81+
id: previous_tag
82+
run: |
83+
PREVIOUS_TAG=$(gh release list --limit 1 --exclude-drafts --exclude-pre-releases --json tagName --jq '.[0].tagName // empty' 2>/dev/null || echo "")
84+
echo "tag=$PREVIOUS_TAG" >> "$GITHUB_OUTPUT"
85+
if [ -n "$PREVIOUS_TAG" ]; then
86+
echo "Previous release tag: $PREVIOUS_TAG"
87+
echo "- Previous release tag: \`$PREVIOUS_TAG\`" >> "$GITHUB_STEP_SUMMARY"
88+
else
89+
echo "No previous release found"
90+
echo "- No previous release found" >> "$GITHUB_STEP_SUMMARY"
91+
fi
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
95+
- name: Create GitHub release
96+
env:
97+
VERSION: ${{ steps.next_version.outputs.version }}
98+
PREVIOUS_TAG: ${{ steps.previous_tag.outputs.tag }}
99+
GH_TOKEN: ${{ github.token }}
100+
run: |
101+
TAG="v${VERSION}"
102+
103+
RELEASE_ARGS=(
104+
"$TAG"
105+
--title "$TAG"
106+
--generate-notes
107+
./*.tgz
108+
)
109+
110+
if [ -n "$PREVIOUS_TAG" ]; then
111+
RELEASE_ARGS+=(--notes-start-tag "$PREVIOUS_TAG")
112+
fi
113+
114+
gh release create "${RELEASE_ARGS[@]}" 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ The Copilot Engine SDK provides everything you need to build an engine that runs
1414
- **CLI** — local testing harness that simulates the platform for development
1515
- **[Integration Guide](docs/integration-guide.md)** — step-by-step guide to building an engine
1616

17-
> **📦 Reference Implementation** — See [`github/agent-platform-engine-example`](https://github.com/github/agent-platform-engine-example) for a complete working engine built with this SDK.
18-
1917
## Installation
2018

2119
Until this package is published to a package registry, install it directly from GitHub:
@@ -242,7 +240,6 @@ Engines receive these environment variables from the platform:
242240
## Documentation
243241

244242
- **[Integration Guide](docs/integration-guide.md)** — step-by-step guide to building an engine from scratch
245-
- **[Example Engine](https://github.com/github/agent-platform-engine-example)** — reference implementation
246243

247244
## Contributing
248245

docs/integration-guide.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
77
This guide walks you through building a custom **engine** — a program that receives a coding task from the Copilot platform, runs an agentic loop against a repository, and streams progress back to users in real time.
88

9-
> **📦 Reference Implementation** — See [`github/agent-platform-engine-example`](https://github.com/github/agent-platform-engine-example) for a complete working engine built with this SDK.
10-
119
## What Is an Engine?
1210

1311
An engine is a program that the platform executes when a user triggers a coding task — such as assigning Copilot to an issue, requesting changes on a PR, or invoking a task via the API. The platform creates a **job**, launches your engine in a secure runner environment, and your engine does the work.
@@ -921,6 +919,69 @@ async function main() {
921919
}
922920
```
923921

922+
## Releasing Your Engine
923+
924+
Engines are consumed via **GitHub Releases** rather than by cloning and building the source repository. Each release should contain a self-contained tarball with everything the platform needs to run your engine: the `engine.yaml` definition and your compiled build output.
925+
926+
### Creating a Release
927+
928+
Tag your commit and push the tag — a GitHub Actions workflow builds the project and publishes the release automatically:
929+
930+
```bash
931+
git tag v1.0.0
932+
git push origin v1.0.0
933+
```
934+
935+
### Release Workflow
936+
937+
Add a workflow that triggers on version tags, builds your engine, and attaches the artifact to a GitHub Release.
938+
939+
> **Note:** The example below is for a Node.js/TypeScript engine. If your engine uses a different runtime (Python, Go, Rust, etc.), substitute the appropriate setup, dependency installation, and build steps, and adjust the artifact paths to match your compiled output.
940+
941+
```yaml
942+
# .github/workflows/release.yml
943+
name: Release
944+
945+
on:
946+
push:
947+
tags:
948+
- 'v*'
949+
950+
permissions:
951+
contents: write
952+
953+
jobs:
954+
release:
955+
runs-on: ubuntu-latest
956+
steps:
957+
- uses: actions/checkout@v4
958+
959+
- uses: actions/setup-node@v4
960+
with:
961+
node-version: 20
962+
cache: npm
963+
964+
- run: npm ci
965+
966+
- run: npm run build
967+
968+
- name: Create release tarball
969+
run: tar -czf engine.tar.gz engine.yaml dist/
970+
971+
- name: Create GitHub Release
972+
uses: softprops/action-gh-release@v2
973+
with:
974+
files: engine.tar.gz
975+
generate_release_notes: true
976+
```
977+
978+
### What to Include in the Release
979+
980+
Your release artifact must include `engine.yaml` and everything it references. The `entrypoint` in `engine.yaml` is resolved as a relative path, so any files or directories it points to need to be in the tarball alongside it. For example, if your entrypoint is `node dist/index.js`, then `dist/index.js` (and any of its runtime dependencies) must be present.
981+
982+
The release should be self-contained — the platform should be able to extract it and run the entrypoint without cloning the repo, installing dependencies, or building from source. This means your build output must include all runtime dependencies. For Node.js engines, either use a bundler (e.g., esbuild, webpack, or ncc) to produce a single self-contained file, or include the `node_modules` directory in the tarball. Other runtimes should follow their equivalent strategy — for example, Go and Rust engines can compile to a static binary, while Python engines might vendor dependencies or include a virtual environment.
983+
984+
924985
## Architecture Notes
925986

926987
### Tokens

0 commit comments

Comments
 (0)