Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
ci: create reusable npm publish workflow
[email protected]5ccdde6c0dd3
diff --git a/.github/workflows/npm-publish-cli.yml b/.github/workflows/npm-publish-cli.ymlindex a71869cce7..5b3e2f79f5 100644--- a/.github/workflows/npm-publish-cli.yml+++ b/.github/workflows/npm-publish-cli.yml@@ -16,7 +16,7 @@ on:default: ""jobs:- build-and-publish:+ build-binaries:permissions:id-token: writecontents: write@@ -51,31 +51,6 @@ jobs:with:bun-version: latest- - name: Get version- id: version- run: |- if [ -n "${{ inputs.version }}" ]; then- EXPECTED_VERSION="${{ inputs.version }}"- elif [ -n "${{ github.event.inputs.version }}" ]; then- EXPECTED_VERSION="${{ github.event.inputs.version }}"- else- EXPECTED_VERSION=$(bun -p "require('./libs/typescript/cua-cli/package.json').version")- fi-- # If version was provided as input, validate it matches package.json- if [ -n "${{ inputs.version }}" ] || [ -n "${{ github.event.inputs.version }}" ]; then- ACTUAL_VERSION=$(bun -p "require('./libs/typescript/cua-cli/package.json').version")- if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then- echo "ERROR: Version mismatch!"- echo "Expected version: $EXPECTED_VERSION"- echo "Actual version in package.json: $ACTUAL_VERSION"- exit 1- fi- echo "Version validation passed: $EXPECTED_VERSION"- fi-- echo "version=${EXPECTED_VERSION}" >> $GITHUB_OUTPUT-- name: Install dependenciesworking-directory: ./libs/typescript/cua-clirun: bun install --frozen-lockfile@@ -96,30 +71,17 @@ jobs:retention-days: 1publish-npm:- needs: build-and-publish- if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cua-v')- runs-on: ubuntu-latest- steps:- - name: Checkout code- uses: actions/checkout@v4-- - name: Setup Bun- uses: oven-sh/setup-bun@v2- with:- bun-version: latest-- - name: Install dependencies- working-directory: ./libs/typescript/cua-cli- run: bun install --frozen-lockfile-- - name: Publish to npm- working-directory: ./libs/typescript/cua-cli- env:- NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}- run: bun publish --production --access public --tolerate-republish+ uses: ./.github/workflows/npm-reusable-publish.yml+ with:+ package_name: "cli"+ package_dir: "libs/typescript/cua-cli"+ package_manager: "bun"+ version: ${{ inputs.version || github.event.inputs.version || '' }}+ secrets:+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}create-release:- needs: [build-and-publish, publish-npm]+ needs: [build-binaries, publish-npm]runs-on: ubuntu-latestpermissions:contents: writediff --git a/.github/workflows/npm-publish-computer.yml b/.github/workflows/npm-publish-computer.ymlindex c5b00d6152..36b8cdbb11 100644--- a/.github/workflows/npm-publish-computer.yml+++ b/.github/workflows/npm-publish-computer.yml@@ -19,65 +19,11 @@ on:jobs:publish:- permissions:- id-token: write- contents: read- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v4-- - name: Use Node.js 24.x- uses: actions/setup-node@v4- with:- node-version: "24.x"- registry-url: "https://registry.npmjs.org"-- - name: Setup pnpm- uses: pnpm/action-setup@v4-- - name: Verify version consistency- if: inputs.version != '' || github.event.inputs.version != ''- run: |- EXPECTED_VERSION="${{ inputs.version }}"- if [ -z "$EXPECTED_VERSION" ]; then- EXPECTED_VERSION="${{ github.event.inputs.version }}"- fi-- ACTUAL_VERSION=$(node -p "require('./libs/typescript/computer/package.json').version")-- if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then- echo "ERROR: Version mismatch!"- echo "Expected version: $EXPECTED_VERSION"- echo "Actual version in package.json: $ACTUAL_VERSION"- exit 1- fi-- echo "Version validation passed: $ACTUAL_VERSION"- echo "should_publish=true" >> $GITHUB_OUTPUT- id: verify-version-- - name: Check if version changed- if: steps.verify-version.outputs.should_publish != 'true'- id: check-version- uses: EndBug/version-check@v2- with:- file-name: libs/typescript/computer/package.json- diff-search: true-- - name: Install dependencies- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/computer- run: pnpm install --frozen-lockfile-- - name: Build package- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/computer- run: pnpm run build --if-present-- - name: Publish to npm- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/computer- run: pnpm publish --access public --no-git-checks- env:- NPM_CONFIG_PROVENANCE: true- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}+ uses: ./.github/workflows/npm-reusable-publish.yml+ with:+ package_name: "computer"+ package_dir: "libs/typescript/computer"+ package_manager: "pnpm"+ version: ${{ inputs.version || github.event.inputs.version || '' }}+ secrets:+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}diff --git a/.github/workflows/npm-publish-core.yml b/.github/workflows/npm-publish-core.ymlindex 2cac541bf0..f2cbfa5c50 100644--- a/.github/workflows/npm-publish-core.yml+++ b/.github/workflows/npm-publish-core.yml@@ -19,65 +19,11 @@ on:jobs:publish:- permissions:- id-token: write- contents: read- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v4-- - name: Use Node.js 24.x- uses: actions/setup-node@v4- with:- node-version: "24.x"- registry-url: "https://registry.npmjs.org"-- - name: Setup pnpm- uses: pnpm/action-setup@v4-- - name: Verify version consistency- if: inputs.version != '' || github.event.inputs.version != ''- run: |- EXPECTED_VERSION="${{ inputs.version }}"- if [ -z "$EXPECTED_VERSION" ]; then- EXPECTED_VERSION="${{ github.event.inputs.version }}"- fi-- ACTUAL_VERSION=$(node -p "require('./libs/typescript/core/package.json').version")-- if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then- echo "ERROR: Version mismatch!"- echo "Expected version: $EXPECTED_VERSION"- echo "Actual version in package.json: $ACTUAL_VERSION"- exit 1- fi-- echo "Version validation passed: $ACTUAL_VERSION"- echo "should_publish=true" >> $GITHUB_OUTPUT- id: verify-version-- - name: Check if version changed- if: steps.verify-version.outputs.should_publish != 'true'- id: check-version- uses: EndBug/version-check@v2- with:- file-name: libs/typescript/core/package.json- diff-search: true-- - name: Install dependencies- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/core- run: pnpm install --frozen-lockfile-- - name: Build package- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/core- run: pnpm run build --if-present-- - name: Publish to npm- if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'- working-directory: ./libs/typescript/core- run: pnpm publish --access public --no-git-checks- env:- NPM_CONFIG_PROVENANCE: true- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}+ uses: ./.github/workflows/npm-reusable-publish.yml+ with:+ package_name: "core"+ package_dir: "libs/typescript/core"+ package_manager: "pnpm"+ version: ${{ inputs.version || github.event.inputs.version || '' }}+ secrets:+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}diff --git a/.github/workflows/npm-reusable-publish.yml b/.github/workflows/npm-reusable-publish.ymlnew file mode 100644index 0000000000..eee82ad43f--- /dev/null+++ b/.github/workflows/npm-reusable-publish.yml@@ -0,0 +1,108 @@+name: Reusable NPM Package Publish Workflow++on:+ workflow_call:+ inputs:+ package_name:+ description: "Name of the package (e.g., cli, computer, core)"+ required: true+ type: string+ package_dir:+ description: "Directory containing the package relative to workspace root (e.g., libs/typescript/cua-cli)"+ required: true+ type: string+ package_manager:+ description: "Package manager to use (pnpm or bun)"+ required: true+ type: string+ version:+ description: "Version to publish (optional - will check version diff if not provided)"+ required: false+ type: string+ default: ""+ secrets:+ NPM_TOKEN:+ required: true++jobs:+ publish:+ permissions:+ id-token: write+ contents: read+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - name: Use Node.js 24.x+ uses: actions/setup-node@v4+ with:+ node-version: "24.x"+ registry-url: "https://registry.npmjs.org"++ - name: Setup pnpm+ if: inputs.package_manager == 'pnpm'+ uses: pnpm/action-setup@v4++ - name: Setup Bun+ if: inputs.package_manager == 'bun'+ uses: oven-sh/setup-bun@v2+ with:+ bun-version: latest++ - name: Verify version consistency+ if: inputs.version != ''+ run: |+ EXPECTED_VERSION="${{ inputs.version }}"+ ACTUAL_VERSION=$(node -p "require('./${{ inputs.package_dir }}/package.json').version")++ if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then+ echo "ERROR: Version mismatch!"+ echo "Expected version: $EXPECTED_VERSION"+ echo "Actual version in package.json: $ACTUAL_VERSION"+ exit 1+ fi++ echo "Version validation passed: $ACTUAL_VERSION"+ echo "should_publish=true" >> $GITHUB_OUTPUT+ id: verify-version++ - name: Check if version changed+ if: steps.verify-version.outputs.should_publish != 'true'+ id: check-version+ uses: EndBug/version-check@v2+ with:+ file-name: ${{ inputs.package_dir }}/package.json+ diff-search: true++ - name: Install dependencies+ if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'+ working-directory: ./${{ inputs.package_dir }}+ run: |+ if [ "${{ inputs.package_manager }}" = "bun" ]; then+ bun install --frozen-lockfile+ else+ pnpm install --frozen-lockfile+ fi++ - name: Build package+ if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'+ working-directory: ./${{ inputs.package_dir }}+ run: |+ if [ "${{ inputs.package_manager }}" = "bun" ]; then+ bun run build --if-present+ else+ pnpm run build --if-present+ fi++ - name: Publish to npm+ if: steps.verify-version.outputs.should_publish == 'true' || steps.check-version.outputs.changed == 'true'+ working-directory: ./${{ inputs.package_dir }}+ run: |+ if [ "${{ inputs.package_manager }}" = "bun" ]; then+ bun publish --production --access public --tolerate-republish+ else+ pnpm publish --access public --no-git-checks+ fi+ env:+ NPM_CONFIG_PROVENANCE: true+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}