Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

👷 ci(cli): publish pkg.pr.new preview builds for CLI PRs (#21745)

Bryanc579fdff37f8
diff --git a/.github/workflows/preview-cli.yml b/.github/workflows/preview-cli.yml
new file mode 100644
index 00000000000..3e901b412a3
--- /dev/null
+++ b/.github/workflows/preview-cli.yml
@@ -0,0 +1,53 @@
+name: Preview CLI
+
+permissions:
+ contents: read
+ pull-requests: write
+
+on:
+ pull_request:
+ paths:
+ - .github/workflows/preview-cli.yml
+ - apps/cli/**
+ - apps/workbench/**
+ - packages/**
+ workflow_dispatch: {}
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ publish-preview:
+ name: Publish CLI preview
+ # Forks cannot publish: the pkg.pr.new app identity belongs to this repo.
+ if: >-
+ github.event_name == 'workflow_dispatch' ||
+ github.event.pull_request.head.repo.full_name == github.repository
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Setup environment
+ uses: ./.github/actions/setup-env
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Install CLI workspace dependencies
+ run: pnpm install
+ working-directory: apps/cli
+
+ # prepublishOnly is the same chain a manual npm publish runs:
+ # workbench build:report -> tsdown bundle -> copyReportTemplate -> man:generate.
+ # npm/pnpm pack does not trigger it, so the build happens here explicitly.
+ - name: Build publishable CLI bundle
+ run: npm run prepublishOnly
+ working-directory: apps/cli
+
+ - name: Smoke check
+ run: node apps/cli/dist/index.js --version
+
+ - name: Publish preview to pkg.pr.new
+ run: pnpm dlx [email protected] publish --pnpm --bin --no-compact --commentWithSha --no-template './apps/cli'