acp: publish goose ACP client and acp binary as separate npm packages (#11846)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
# This is a reusable workflow that builds the CLI for multiple platforms.
|
||||
# It doesn't get triggered on its own. It gets used by:
|
||||
# - publish-npm.yml
|
||||
#
|
||||
# Platform Build Strategy:
|
||||
# - Linux standard (x86_64 + aarch64): Builds inside manylinux_2_28 container for glibc 2.28+ compat
|
||||
|
||||
@@ -32,6 +32,40 @@ jobs:
|
||||
code:
|
||||
- '!documentation/**'
|
||||
|
||||
goose-acp-npm-packages:
|
||||
name: goose ACP npm packages
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Install dependencies
|
||||
run: source bin/activate-hermit && pnpm --dir ui install --frozen-lockfile
|
||||
|
||||
- name: Check npm versions
|
||||
run: source bin/activate-hermit && node ui/scripts/npm-versions.mjs check
|
||||
|
||||
- name: Test goose-acp
|
||||
run: source bin/activate-hermit && pnpm --dir ui/goose-acp test
|
||||
|
||||
- name: Pack npm packages
|
||||
run: |
|
||||
source bin/activate-hermit
|
||||
set -euo pipefail
|
||||
client_pack_dir="$RUNNER_TEMP/goose-acp-client"
|
||||
wrapper_pack_dir="$RUNNER_TEMP/goose-acp"
|
||||
mkdir -p "$client_pack_dir" "$wrapper_pack_dir"
|
||||
|
||||
pnpm --dir ui/goose-acp-client pack --pack-destination "$client_pack_dir"
|
||||
pnpm --dir ui/goose-acp pack --pack-destination "$wrapper_pack_dir"
|
||||
|
||||
wrapper_tarball=$(find "$wrapper_pack_dir" -name '*.tgz' -print -quit)
|
||||
tar -xzf "$wrapper_tarball" -C "$wrapper_pack_dir"
|
||||
node ui/scripts/npm-versions.mjs check-packed-wrapper \
|
||||
"$wrapper_pack_dir/package/package.json"
|
||||
|
||||
rust-format:
|
||||
name: Check Rust Code Format
|
||||
runs-on: ubuntu-latest
|
||||
@@ -273,7 +307,6 @@ jobs:
|
||||
run: |
|
||||
source ./bin/activate-hermit
|
||||
cd ui/desktop && pnpm install --frozen-lockfile
|
||||
cd ../sdk && pnpm install --frozen-lockfile
|
||||
|
||||
- name: Check ACP Artifacts are Up-to-Date
|
||||
run: |
|
||||
@@ -283,7 +316,7 @@ jobs:
|
||||
- name: Check ACP Client SDK
|
||||
run: |
|
||||
source ./bin/activate-hermit
|
||||
cd ui/sdk
|
||||
cd ui/goose-acp-client
|
||||
pnpm run lint
|
||||
|
||||
gdk-api-docs-check:
|
||||
|
||||
@@ -1,215 +1,74 @@
|
||||
name: Publish to npm
|
||||
name: Goose ACP npm release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
inputs:
|
||||
release_tag:
|
||||
description: Versioned Goose release to package, for example v1.49.0
|
||||
required: true
|
||||
type: string
|
||||
publish:
|
||||
description: Publish the verified tarballs to npm
|
||||
required: true
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build-cli:
|
||||
uses: ./.github/workflows/build-cli.yml
|
||||
|
||||
# Build npm packages (no environment needed)
|
||||
build:
|
||||
name: Build npm packages
|
||||
pack:
|
||||
name: Pack npm packages
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-cli]
|
||||
outputs:
|
||||
version: ${{ steps.prepare.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: Checkout release tag
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '24.10.0'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
always-auth: true
|
||||
ref: ${{ inputs.release_tag }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with:
|
||||
version: 10.30.3
|
||||
|
||||
- name: Download freshly-built goose CLI binaries
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
pattern: goose-*
|
||||
path: /tmp/cli-artifacts
|
||||
|
||||
- name: Place binaries into goose-binary packages
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "Available CLI artifacts:"
|
||||
find /tmp/cli-artifacts -maxdepth 2 -type d | sort
|
||||
|
||||
# Map: npm platform name -> upstream artifact directory name (target triple)
|
||||
declare -A PLATFORM_MAP=(
|
||||
[darwin-arm64]=aarch64-apple-darwin
|
||||
[darwin-x64]=x86_64-apple-darwin
|
||||
[linux-arm64]=aarch64-unknown-linux-gnu
|
||||
[linux-x64]=x86_64-unknown-linux-gnu
|
||||
[win32-x64]=x86_64-pc-windows-msvc
|
||||
)
|
||||
|
||||
for platform in "${!PLATFORM_MAP[@]}"; do
|
||||
target="${PLATFORM_MAP[$platform]}"
|
||||
artifact_dir="/tmp/cli-artifacts/goose-${target}"
|
||||
pkg_dir="ui/goose-binary/goose-binary-${platform}/bin"
|
||||
mkdir -p "${pkg_dir}"
|
||||
|
||||
if [[ "${platform}" == "win32-x64" ]]; then
|
||||
archive="${artifact_dir}/goose-${target}.zip"
|
||||
if [[ ! -f "${archive}" ]]; then
|
||||
echo "::error::Missing Windows CLI artifact: ${archive}"
|
||||
exit 1
|
||||
fi
|
||||
rm -rf /tmp/goose-extract
|
||||
unzip -o "${archive}" -d /tmp/goose-extract
|
||||
cp /tmp/goose-extract/goose-package/goose.exe "${pkg_dir}/goose.exe"
|
||||
else
|
||||
archive="${artifact_dir}/goose-${target}.tar.bz2"
|
||||
if [[ ! -f "${archive}" ]]; then
|
||||
echo "::error::Missing CLI artifact: ${archive}"
|
||||
exit 1
|
||||
fi
|
||||
rm -rf /tmp/goose-extract
|
||||
mkdir -p /tmp/goose-extract
|
||||
tar -xjf "${archive}" -C /tmp/goose-extract
|
||||
cp /tmp/goose-extract/goose "${pkg_dir}/goose"
|
||||
chmod +x "${pkg_dir}/goose"
|
||||
fi
|
||||
|
||||
echo " ✅ ${platform} (${target})"
|
||||
done
|
||||
|
||||
- name: List downloaded binaries (debug)
|
||||
run: find ui/goose-binary -name 'goose*' -type f | sort
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd ui
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build packages
|
||||
run: |
|
||||
cd ui/sdk
|
||||
pnpm run build:ts
|
||||
|
||||
- name: Compatibility check (SDK client ↔ goose binary)
|
||||
- name: Prepare npm package tarballs
|
||||
id: prepare
|
||||
env:
|
||||
GOOSE_BINARY: ${{ github.workspace }}/ui/goose-binary/goose-binary-linux-x64/bin/goose
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
cd ui/sdk
|
||||
pnpm run check:compat
|
||||
bash ui/scripts/prepare-npm-packages.sh \
|
||||
"$RELEASE_TAG" "$RUNNER_TEMP/npm-packages"
|
||||
echo "version=${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload built packages
|
||||
- name: Upload npm package tarballs
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: npm-packages
|
||||
path: ui/
|
||||
name: npm-packages-${{ steps.prepare.outputs.version }}
|
||||
path: ${{ runner.temp }}/npm-packages
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
- name: Build summary
|
||||
run: |
|
||||
{
|
||||
echo "## 📦 Build Summary"
|
||||
echo ""
|
||||
echo "### Source"
|
||||
echo "Commit: \`${GITHUB_SHA}\`"
|
||||
echo ""
|
||||
echo "### Goose CLI Binaries"
|
||||
echo "✅ Built from this commit for all platforms:"
|
||||
for dir in ui/goose-binary/goose-binary-*/; do
|
||||
platform=$(basename "$dir" | sed 's/goose-binary-//')
|
||||
echo " - $platform"
|
||||
done
|
||||
echo ""
|
||||
echo "### npm Packages"
|
||||
cd ui
|
||||
for pkg in sdk goose-binary/*/; do
|
||||
if [ -f "$pkg/package.json" ]; then
|
||||
name=$(jq -r '.name' "$pkg/package.json")
|
||||
version=$(jq -r '.version' "$pkg/package.json")
|
||||
echo "- $name@$version"
|
||||
fi
|
||||
done
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
retention-days: 30
|
||||
|
||||
publish:
|
||||
name: Publish to npm
|
||||
name: Publish npm packages
|
||||
if: ${{ inputs.publish }}
|
||||
needs: pack
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
environment: npm-production-publishing
|
||||
permissions:
|
||||
id-token: write # Required for npm trusted publishing (OIDC)
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Download built packages
|
||||
- name: Checkout release tag
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.release_tag }}
|
||||
|
||||
- name: Download npm package tarballs
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: npm-packages
|
||||
path: ui/
|
||||
name: npm-packages-${{ needs.pack.outputs.version }}
|
||||
path: ${{ runner.temp }}/npm-packages
|
||||
|
||||
- name: Restore executable bits on goose binaries
|
||||
run: find ui/goose-binary -name 'goose' -type f -exec chmod +x {} +
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '24.10.0'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
always-auth: true
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
with:
|
||||
version: 10.30.3
|
||||
|
||||
- name: Publish to npm
|
||||
run: |
|
||||
cd ui
|
||||
# Publish each package individually so one failure doesn't abort the rest.
|
||||
# Skips packages whose version is already published (409/403).
|
||||
failed=0
|
||||
for pkg in sdk goose-binary/*/; do
|
||||
if [ -f "$pkg/package.json" ]; then
|
||||
name=$(jq -r '.name' "$pkg/package.json")
|
||||
version=$(jq -r '.version' "$pkg/package.json")
|
||||
echo "Publishing $name@$version..."
|
||||
if (cd "$pkg" && pnpm publish --access public --no-git-checks --provenance); then
|
||||
echo " ✅ $name@$version published"
|
||||
else
|
||||
# Check if it failed because the version already exists
|
||||
if npm view "$name@$version" version > /dev/null 2>&1; then
|
||||
echo " ⏭️ $name@$version already published, skipping"
|
||||
else
|
||||
echo " ❌ $name@$version failed to publish"
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "$failed" -eq 1 ]; then
|
||||
echo "::error::One or more packages failed to publish"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Publish summary
|
||||
if: always()
|
||||
run: |
|
||||
cd ui
|
||||
{
|
||||
echo "## 🚀 Published Packages"
|
||||
echo ""
|
||||
for pkg in sdk goose-binary/*/; do
|
||||
if [ -f "$pkg/package.json" ]; then
|
||||
name=$(jq -r '.name' "$pkg/package.json")
|
||||
version=$(jq -r '.version' "$pkg/package.json")
|
||||
echo "- $name@$version"
|
||||
fi
|
||||
done
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
- name: Publish verified tarballs
|
||||
env:
|
||||
PACK_DIR: ${{ runner.temp }}/npm-packages
|
||||
RELEASE_VERSION: ${{ needs.pack.outputs.version }}
|
||||
run: bash ui/scripts/publish-npm-packages.sh "$PACK_DIR" "$RELEASE_VERSION"
|
||||
|
||||
Reference in New Issue
Block a user