Skip to main content
EVOKORE// WORKFLOWS / build-cli-binaries.yml
ComposioHQ/composioworkflow · 214 lines

workflows/build-cli-binaries.yml

CI / automation

View on GitHub →
# REFERENCE-ONLY: GitHub Actions secrets referenced below are illustrative.
# Do not inject real credentials. See your CI/CD provider for proper secret management.
name: Build CLI Binaries

on:
  release:
    types: [published]
  workflow_dispatch:
    inputs:
      version:
        description: 'Semver version to release (e.g., 1.0.0)'
        required: true

permissions:
  contents: write

jobs:
  build:
    name: Build ${{ matrix.artifact }}
    if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, '@composio/cli@') || startsWith(github.event.release.tag_name, 'v')
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - target: bun-linux-x64
            artifact: composio-linux-x64
          - target: bun-linux-arm64
            artifact: composio-linux-aarch64
          - target: bun-darwin-x64
            artifact: composio-darwin-x64
          - target: bun-darwin-arm64
            artifact: composio-darwin-aarch64

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Validate manual version input
        if: github.event_name == 'workflow_dispatch'
        run: |
          version="${{ inputs.version }}"
          if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
            echo "Invalid semver version: '$version'"
            echo "Expected format like: 1.2.3, 1.2.3-beta.1, 1.2.3+build.7"
            exit 1
          fi

      - name: Setup Node.js, pnpm, Bun
        uses: ./.github/actions/setup-node-pnpm-bun

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Build packages
        run: pnpm build:packages

      - name: Cross-compile CLI binary
        working-directory: ts/packages/cli
        run: pnpm build:binary:cross --target ${{ matrix.target }}

      - name: Verify binary
        working-directory: ts/packages/cli
        run: |
          ls -la dist/binaries/${{ matrix.artifact }}
          file dist/binaries/${{ matrix.artifact }}

      - name: Test binary
        if: matrix.target == 'bun-linux-x64'
        working-directory: ts/packages/cli
        env:
          COMPOSIO_USER_API_KEY: <YOUR_API_KEY>
        run: |
          ./dist/binaries/${{ matrix.artifact }} --version
          ./dist/binaries/${{ matrix.artifact }} --help | head -5

      - name: Create archive
        working-directory: ts/packages/cli/dist/binaries
        run: |
          # Create subdirectory structure expected by install script
          # Use a temp directory name to avoid name collision with the binary file
          temp_dir="archive-${{ matrix.artifact }}"
          rm -rf "$temp_dir"
          mkdir -p "$temp_dir/${{ matrix.artifact }}"
          cp "${{ matrix.artifact }}" "$temp_dir/${{ matrix.artifact }}/composio"
          cd "$temp_dir" && zip -r "../${{ matrix.artifact }}.zip" "${{ matrix.artifact }}"
          cd .. && rm -r "$temp_dir"

      - name: Upload artifact
        uses: actions/upload-artifact@v6
        with:
          name: ${{ matrix.artifact }}
          path: ts/packages/cli/dist/binaries/${{ matrix.artifact }}.zip
          retention-days: 7

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Setup Node.js, pnpm, Bun
        uses: ./.github/actions/setup-node-pnpm-bun

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Download all artifacts
        uses: actions/download-artifact@v6
        with:
          path: ts/packages/cli/dist/binaries
          merge-multiple: true

      - name: Generate checksums
        working-directory: ts/packages/cli
        run: bun run ./scripts/generate-checksums.ts

      - name: Display checksums
        run: cat ts/packages/cli/dist/binaries/checksums.txt

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}
          name: ${{ github.event_name == 'workflow_dispatch' && format('CLI @composio/cli@{0} (Manual Build)', inputs.version) || github.event.release.tag_name }}
          files: |
            ts/packages/cli/dist/binaries/*.zip
            ts/packages/cli/dist/binaries/checksums.txt
          draft: false
          prerelease: ${{ github.event_name == 'workflow_dispatch' || github.event.release.prerelease || contains(github.event.release.tag_name, 'alpha') || contains(github.event.release.tag_name, 'beta') || contains(github.event.release.tag_name, 'rc') }}
          generate_release_notes: true
          make_latest: ${{ github.event_name != 'workflow_dispatch' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  test-installation:
    name: Test Installation
    needs: release
    if: always() && !cancelled() && needs.release.result == 'success'
    uses: ./.github/workflows/cli.test-installation.yml
    with:
      version: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}

  create-install-instructions:
    name: Create Install Instructions
    needs: release
    runs-on: ubuntu-latest
    if: always() && !cancelled() && needs.release.result == 'success'

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Create installation README
        run: |
          RELEASE_TAG="${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}"
          cat > INSTALL.md << 'EOF'
          # Composio CLI Installation

          ## Quick Install (Recommended)

          ### Linux and macOS
          ```bash
          curl -fsSL https://raw.githubusercontent.com/ComposioHQ/composio/main/install.sh | bash
          ```

          ### Install specific version
          ```bash
          curl -fsSL https://raw.githubusercontent.com/ComposioHQ/composio/main/install.sh | bash -s -- RELEASE_TAG_PLACEHOLDER
          ```

          ## Manual Installation

          1. Download the appropriate binary for your platform from the [releases page](https://github.com/ComposioHQ/composio/releases)
          2. Extract the binary
          3. Move it to a directory in your PATH (e.g., `/usr/local/bin`)
          4. Make it executable: `chmod +x composio`

          ## Alternative: npm/pnpm Installation

          ```bash
          npm install -g @composio/cli
          # or
          pnpm add -g @composio/cli
          ```

          ## Usage

          ```bash
          composio --help
          composio login
          composio generate
          ```

          ## Supported Platforms

          - Linux x64
          - Linux ARM64
          - macOS x64 (Intel)
          - macOS ARM64 (Apple Silicon)

          Windows support coming soon!
          EOF
          sed -i.bak "s|RELEASE_TAG_PLACEHOLDER|$RELEASE_TAG|g" INSTALL.md && rm -f INSTALL.md.bak

      - name: Upload install instructions
        uses: actions/upload-artifact@v6
        with:
          name: install-instructions
          path: INSTALL.md