Skip to content
Draft
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
100 changes: 100 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: npm

on:
release:
types: [published]
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to publish (e.g., v1.34.0)"
required: true
type: string
dry_run:
description: "Dry run (do not publish to npm)"
required: false
type: boolean
default: false

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642195f882660b323136e12 # v4.4.0
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- name: Determine version
id: version
run: |
TAG="${{ inputs.release_tag || github.event.release.tag_name }}"
VERSION="${TAG#v}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Cross-compile binaries
run: |
docker buildx build \
--target=cross \
--build-arg GIT_TAG="${{ steps.version.outputs.tag }}" \
--build-arg GIT_COMMIT="${{ github.sha }}" \
--platform linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 \
--output=./dist \
.
- name: Package npm packages
run: |
chmod +x npm/scripts/package.sh
./npm/scripts/package.sh "${{ steps.version.outputs.version }}"
- name: Verify packages
run: |
echo "=== Main package ==="
cat npm/docker-agent/package.json
echo ""
echo "=== Platform packages ==="
for pkg in npm/docker-agent-*/; do
echo "--- $(basename "$pkg") ---"
cat "$pkg/package.json"
ls -lh "$pkg/"
echo ""
done
- name: Publish platform packages
if: ${{ !inputs.dry_run }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for pkg in npm/docker-agent-*/; do
echo "Publishing $(basename "$pkg")..."
(cd "$pkg" && npm publish --access public)
done
- name: Publish main package
if: ${{ !inputs.dry_run }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "Publishing @docker/docker-agent..."
cd npm/docker-agent && npm publish --access public
- name: Dry run - show what would be published
if: ${{ inputs.dry_run }}
run: |
for pkg in npm/docker-agent-*/; do
echo "=== Would publish $(basename "$pkg") ==="
(cd "$pkg" && npm pack --dry-run)
echo ""
done
echo "=== Would publish @docker/docker-agent ==="
(cd npm/docker-agent && npm pack --dry-run)
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ vendor
/cagent
/cagent-*
/docker-mcp-*

# npm platform binaries (copied in by npm/scripts/package.sh)
npm/docker-agent-*/docker-agent
npm/docker-agent-*/docker-agent.exe
npm/docker-agent/LICENSE
npm/docker-agent/README.md
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ docker agent run agent.yaml

**Homebrew** — `brew install docker-agent`. Run `docker-agent` directly or symlink the binary to `~/.docker/cli-plugins/docker-agent` and run `docker agent`.

**npm** — `npx -y @docker/docker-agent` to run directly, or `npm install -g @docker/docker-agent` to install globally.

**Binary releases** — Download from [GitHub Releases](https://github.com/docker/docker-agent/releases). Symlink the `docker-agent` binary to `~/.docker/cli-plugins/docker-agent` to be able to use `docker agent`, or use `docker-agent` directly.

Set at least one API key (or use [Docker Model Runner](https://docs.docker.com/ai/model-runner/) for local models):
Expand Down
9 changes: 9 additions & 0 deletions npm/docker-agent-darwin-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-darwin-arm64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-darwin-arm64",
"version": "0.0.0",
"description": "Docker Agent binary for macOS ARM64 (Apple Silicon)",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["darwin"],
"cpu": ["arm64"],
"files": [
"docker-agent"
]
}
9 changes: 9 additions & 0 deletions npm/docker-agent-darwin-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-darwin-x64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-darwin-x64",
"version": "0.0.0",
"description": "Docker Agent binary for macOS x64 (Intel)",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["darwin"],
"cpu": ["x64"],
"files": [
"docker-agent"
]
}
9 changes: 9 additions & 0 deletions npm/docker-agent-linux-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-linux-arm64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-linux-arm64",
"version": "0.0.0",
"description": "Docker Agent binary for Linux ARM64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["linux"],
"cpu": ["arm64"],
"files": [
"docker-agent"
]
}
9 changes: 9 additions & 0 deletions npm/docker-agent-linux-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-linux-x64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-linux-x64",
"version": "0.0.0",
"description": "Docker Agent binary for Linux x64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["linux"],
"cpu": ["x64"],
"files": [
"docker-agent"
]
}
9 changes: 9 additions & 0 deletions npm/docker-agent-win32-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-win32-arm64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-win32-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-win32-arm64",
"version": "0.0.0",
"description": "Docker Agent binary for Windows ARM64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["win32"],
"cpu": ["arm64"],
"files": [
"docker-agent.exe"
]
}
9 changes: 9 additions & 0 deletions npm/docker-agent-win32-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @docker/docker-agent-win32-x64

Platform-specific binary package for [Docker Agent](https://github.com/docker/docker-agent).

This package is installed automatically by `@docker/docker-agent` — you don't need to install it directly.

```sh
npx -y @docker/docker-agent
```
15 changes: 15 additions & 0 deletions npm/docker-agent-win32-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@docker/docker-agent-win32-x64",
"version": "0.0.0",
"description": "Docker Agent binary for Windows x64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"os": ["win32"],
"cpu": ["x64"],
"files": [
"docker-agent.exe"
]
}
36 changes: 36 additions & 0 deletions npm/docker-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@docker/docker-agent",
"version": "0.0.0",
"description": "Docker Agent - Build, run, and share AI agents",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/docker/docker-agent.git"
},
"homepage": "https://docker.github.io/docker-agent/",
"bugs": "https://github.com/docker/docker-agent/issues",
"bin": {
"docker-agent": "bin/cli.js"
},
"files": [
"bin/cli.js",
"README.md",
"LICENSE"
],
"optionalDependencies": {
"@docker/docker-agent-darwin-arm64": "0.0.0",
"@docker/docker-agent-darwin-x64": "0.0.0",
"@docker/docker-agent-linux-arm64": "0.0.0",
"@docker/docker-agent-linux-x64": "0.0.0",
"@docker/docker-agent-win32-arm64": "0.0.0",
"@docker/docker-agent-win32-x64": "0.0.0"
},
"keywords": [
"docker",
"agent",
"ai",
"coding-agent",
"cli",
"mcp"
]
}
75 changes: 75 additions & 0 deletions npm/scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
#
# npm/scripts/package.sh
#
# Prepares npm packages for publishing by:
# 1. Copying cross-compiled binaries from dist/ into the platform packages
# 2. Stamping all package.json files with the given version
# 3. Copying LICENSE and README into the main package
#
# Usage: ./npm/scripts/package.sh <version>
#
# Expects the dist/ directory to contain cross-compiled binaries produced
# by `task cross` (docker buildx --output=./dist), with the structure:
# dist/<goos>_<goarch>/docker-agent-<goos>-<goarch> (unix)
# dist/<goos>_<goarch>/docker-agent-<goos>-<goarch>.exe (windows)

set -euo pipefail

VERSION="${1:?Usage: $0 <version>}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
NPM_DIR="$ROOT_DIR/npm"
DIST_DIR="$ROOT_DIR/dist"

# Mapping: npm-platform-arch -> dist-subdir/binary-name -> npm-binary-name
# key: npm platform suffix (e.g., darwin-arm64)
# value: "<dist_subdir>/<src_binary>|<dest_binary>"
declare -A PLATFORM_MAP=(
["darwin-arm64"]="darwin_arm64/docker-agent-darwin-arm64|docker-agent"
["darwin-x64"]="darwin_amd64/docker-agent-darwin-amd64|docker-agent"
["linux-arm64"]="linux_arm64/docker-agent-linux-arm64|docker-agent"
["linux-x64"]="linux_amd64/docker-agent-linux-amd64|docker-agent"
["win32-arm64"]="windows_arm64/docker-agent-windows-arm64.exe|docker-agent.exe"
["win32-x64"]="windows_amd64/docker-agent-windows-amd64.exe|docker-agent.exe"
)

echo "Packaging npm packages for version ${VERSION}..."

# --- Step 1: Copy binaries into platform packages ---
for npm_platform in "${!PLATFORM_MAP[@]}"; do
mapping="${PLATFORM_MAP[$npm_platform]}"
src_rel="${mapping%%|*}"
dest_name="${mapping##*|}"
src="${DIST_DIR}/${src_rel}"
pkg_dir="${NPM_DIR}/docker-agent-${npm_platform}"

if [ ! -f "$src" ]; then
echo "ERROR: Binary not found: $src"
echo " Run 'task cross' first to build all platform binaries."
exit 1
fi

echo " Copying $src -> $pkg_dir/$dest_name"
cp "$src" "$pkg_dir/$dest_name"
chmod +x "$pkg_dir/$dest_name"
done

# --- Step 2: Stamp version in all package.json files ---
echo " Setting version to ${VERSION} in all package.json files..."
for pkg_json in "$NPM_DIR"/*/package.json; do
sed -i.bak "s/\"0.0.0\"/\"${VERSION}\"/g" "$pkg_json"
rm -f "${pkg_json}.bak"
done

# --- Step 3: Copy LICENSE and README into main package ---
cp "$ROOT_DIR/LICENSE" "$NPM_DIR/docker-agent/LICENSE"
cp "$ROOT_DIR/README.md" "$NPM_DIR/docker-agent/README.md"

echo ""
echo "Done. Packages ready in ${NPM_DIR}/"
echo ""
echo "To publish (platform packages first, then main package):"
echo " cd ${NPM_DIR}"
echo " for pkg in docker-agent-*/; do (cd \"\$pkg\" && npm publish --access public); done"
echo " cd docker-agent && npm publish --access public"
Loading