ci: add auto-publish support for all pypi/npm packages

This commit is contained in:
synacktra.work@gmail.com
2025-12-30 16:59:49 +05:30
parent 0feb795cde
commit 9bb90ad7e2

View File

@@ -8,13 +8,15 @@ on:
required: true
type: choice
options:
- cua-agent
- cua-computer
- cua-computer-server
- cua-core
- cua-mcp-server
- cua-som
- pylume
- pypi/agent
- pypi/computer
- pypi/computer-server
- pypi/core
- pypi/mcp-server
- pypi/som
- npm/cli
- npm/computer
- npm/core
bump_type:
description: "Version bump type"
required: true
@@ -33,31 +35,53 @@ jobs:
outputs:
agent_version: ${{ steps.agent_version.outputs.version }}
computer_version: ${{ steps.computer_version.outputs.version }}
computer_server_version: ${{ steps.computer_server_version.outputs.version }}
core_version: ${{ steps.core_version.outputs.version }}
mcp_server_version: ${{ steps.mcp_server_version.outputs.version }}
som_version: ${{ steps.som_version.outputs.version }}
npm_cli_version: ${{ steps.npm_cli_version.outputs.version }}
npm_computer_version: ${{ steps.npm_computer_version.outputs.version }}
npm_core_version: ${{ steps.npm_core_version.outputs.version }}
steps:
- name: Set package directory
- name: Set package directory and type
id: package
run: |
case "${{ inputs.service }}" in
"cua-agent")
"pypi/agent")
echo "directory=libs/python/agent" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"cua-computer")
"pypi/computer")
echo "directory=libs/python/computer" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"cua-computer-server")
"pypi/computer-server")
echo "directory=libs/python/computer-server" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"cua-core")
"pypi/core")
echo "directory=libs/python/core" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"cua-mcp-server")
"pypi/mcp-server")
echo "directory=libs/python/mcp-server" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"cua-som")
"pypi/som")
echo "directory=libs/python/som" >> $GITHUB_OUTPUT
echo "type=python" >> $GITHUB_OUTPUT
;;
"pylume")
echo "directory=libs/python/pylume" >> $GITHUB_OUTPUT
"npm/cli")
echo "directory=libs/typescript/cua-cli" >> $GITHUB_OUTPUT
echo "type=npm" >> $GITHUB_OUTPUT
;;
"npm/computer")
echo "directory=libs/typescript/computer" >> $GITHUB_OUTPUT
echo "type=npm" >> $GITHUB_OUTPUT
;;
"npm/core")
echo "directory=libs/typescript/core" >> $GITHUB_OUTPUT
echo "type=npm" >> $GITHUB_OUTPUT
;;
*)
echo "Unknown service: ${{ inputs.service }}"
@@ -72,31 +96,66 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
if: ${{ steps.package.outputs.type == 'python' }}
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install bump2version
if: ${{ steps.package.outputs.type == 'python' }}
run: pip install bump2version
- name: Set up Node.js
if: ${{ steps.package.outputs.type == 'npm' }}
uses: actions/setup-node@v4
with:
node-version: "24.x"
- name: Setup pnpm
if: ${{ steps.package.outputs.type == 'npm' && inputs.service != 'npm/cli' }}
uses: pnpm/action-setup@v4
- name: Setup Bun
if: ${{ inputs.service == 'npm/cli' }}
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install bumpp for npm packages
if: ${{ steps.package.outputs.type == 'npm' }}
run: npm install -g bumpp
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Run bump2version
- name: Run bump2version (Python)
if: ${{ steps.package.outputs.type == 'python' }}
run: |
cd ${{ steps.package.outputs.directory }}
bump2version ${{ inputs.bump_type }}
- name: Run bumpp (NPM)
if: ${{ steps.package.outputs.type == 'npm' }}
run: |
cd ${{ steps.package.outputs.directory }}
bumpp --${{ inputs.bump_type }} --yes --no-push --no-tag --no-commit
- name: Commit NPM version changes
if: ${{ steps.package.outputs.type == 'npm' }}
run: |
git add ${{ steps.package.outputs.directory }}/package.json
git commit -m "chore: bump ${{ inputs.service }} version to ${{ inputs.bump_type }}"
- name: Also bump cua-agent
if: ${{ inputs.service == 'cua-computer' }}
if: ${{ inputs.service == 'pypi/computer' }}
run: |
cd libs/python/agent
bump2version ${{ inputs.bump_type }}
- name: Capture bumped agent version
if: ${{ inputs.service == 'cua-agent' || inputs.service == 'cua-computer' }}
if: ${{ inputs.service == 'pypi/agent' || inputs.service == 'pypi/computer' }}
id: agent_version
run: |
cd libs/python/agent
@@ -105,7 +164,7 @@ jobs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped computer version
if: ${{ inputs.service == 'cua-computer' }}
if: ${{ inputs.service == 'pypi/computer' }}
id: computer_version
run: |
cd libs/python/computer
@@ -113,13 +172,76 @@ jobs:
echo "Computer version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped computer-server version
if: ${{ inputs.service == 'pypi/computer-server' }}
id: computer_server_version
run: |
cd libs/python/computer-server
VERSION=$(python -c "import tomllib; from pathlib import Path; data = tomllib.loads(Path('pyproject.toml').read_text()); print(data['project']['version'])")
echo "Computer-server version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped core version
if: ${{ inputs.service == 'pypi/core' }}
id: core_version
run: |
cd libs/python/core
VERSION=$(python -c "import tomllib; from pathlib import Path; data = tomllib.loads(Path('pyproject.toml').read_text()); print(data['project']['version'])")
echo "Core version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped mcp-server version
if: ${{ inputs.service == 'pypi/mcp-server' }}
id: mcp_server_version
run: |
cd libs/python/mcp-server
VERSION=$(python -c "import tomllib; from pathlib import Path; data = tomllib.loads(Path('pyproject.toml').read_text()); print(data['project']['version'])")
echo "MCP-server version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped som version
if: ${{ inputs.service == 'pypi/som' }}
id: som_version
run: |
cd libs/python/som
VERSION=$(python -c "import tomllib; from pathlib import Path; data = tomllib.loads(Path('pyproject.toml').read_text()); print(data['project']['version'])")
echo "SOM version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped npm/cli version
if: ${{ inputs.service == 'npm/cli' }}
id: npm_cli_version
run: |
cd libs/typescript/cua-cli
VERSION=$(node -p "require('./package.json').version")
echo "npm/cli version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped npm/computer version
if: ${{ inputs.service == 'npm/computer' }}
id: npm_computer_version
run: |
cd libs/typescript/computer
VERSION=$(node -p "require('./package.json').version")
echo "npm/computer version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Capture bumped npm/core version
if: ${{ inputs.service == 'npm/core' }}
id: npm_core_version
run: |
cd libs/typescript/core
VERSION=$(node -p "require('./package.json').version")
echo "npm/core version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Push changes
run: |
git push origin main --follow-tags
publish-computer:
needs: bump-version
if: ${{ inputs.service == 'cua-computer' }}
if: ${{ inputs.service == 'pypi/computer' }}
uses: ./.github/workflows/pypi-publish-computer.yml
with:
version: ${{ needs.bump-version.outputs.computer_version }}
@@ -127,8 +249,64 @@ jobs:
publish-agent:
needs: [bump-version, publish-computer]
if: ${{ always() && (inputs.service == 'cua-agent' || inputs.service == 'cua-computer') && needs.bump-version.result == 'success' && (inputs.service == 'cua-agent' || needs.publish-computer.result == 'success') }}
if: ${{ always() && (inputs.service == 'pypi/agent' || inputs.service == 'pypi/computer') && needs.bump-version.result == 'success' && (inputs.service == 'pypi/agent' || needs.publish-computer.result == 'success') }}
uses: ./.github/workflows/pypi-publish-agent.yml
with:
version: ${{ needs.bump-version.outputs.agent_version }}
secrets: inherit
publish-computer-server:
needs: bump-version
if: ${{ inputs.service == 'pypi/computer-server' }}
uses: ./.github/workflows/pypi-publish-computer-server.yml
with:
version: ${{ needs.bump-version.outputs.computer_server_version }}
secrets: inherit
publish-core:
needs: bump-version
if: ${{ inputs.service == 'pypi/core' }}
uses: ./.github/workflows/pypi-publish-core.yml
with:
version: ${{ needs.bump-version.outputs.core_version }}
secrets: inherit
publish-mcp-server:
needs: bump-version
if: ${{ inputs.service == 'pypi/mcp-server' }}
uses: ./.github/workflows/pypi-publish-mcp-server.yml
with:
version: ${{ needs.bump-version.outputs.mcp_server_version }}
secrets: inherit
publish-som:
needs: bump-version
if: ${{ inputs.service == 'pypi/som' }}
uses: ./.github/workflows/pypi-publish-som.yml
with:
version: ${{ needs.bump-version.outputs.som_version }}
secrets: inherit
publish-cli:
needs: bump-version
if: ${{ inputs.service == 'npm/cli' }}
uses: ./.github/workflows/npm-publish-cli.yml
with:
version: ${{ needs.bump-version.outputs.npm_cli_version }}
secrets: inherit
publish-npm-computer:
needs: bump-version
if: ${{ inputs.service == 'npm/computer' }}
uses: ./.github/workflows/npm-publish-computer.yml
with:
version: ${{ needs.bump-version.outputs.npm_computer_version }}
secrets: inherit
publish-npm-core:
needs: bump-version
if: ${{ inputs.service == 'npm/core' }}
uses: ./.github/workflows/npm-publish-core.yml
with:
version: ${{ needs.bump-version.outputs.npm_core_version }}
secrets: inherit