name: "CD: @trycua/cli (npm)" on: push: tags: - "npm-cli-v*" workflow_dispatch: inputs: version: description: "Version to publish (default: from package.json)" required: false default: "" workflow_call: inputs: version: description: "Version to publish (default: from package.json)" required: false type: string default: "" permissions: id-token: write contents: write packages: write jobs: prepare: runs-on: ubuntu-latest outputs: version: ${{ steps.get-version.outputs.version }} tag: ${{ steps.get-version.outputs.tag }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Determine version id: get-version run: | # Check inputs.version first (works for workflow_call) if [ -n "${{ inputs.version }}" ]; then VERSION="${{ inputs.version }}" elif [ "${{ github.event_name }}" == "push" ]; then # Extract version from tag if [[ "${{ github.ref }}" =~ ^refs/tags/npm-cli-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then VERSION=${BASH_REMATCH[1]} else echo "ERROR: Invalid tag format for npm-cli" exit 1 fi elif [ -n "${{ github.event.inputs.version }}" ]; then VERSION="${{ github.event.inputs.version }}" else # Read from package.json VERSION=$(node -p "require('./libs/typescript/cua-cli/package.json').version") fi echo "CLI version: $VERSION" echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tag=npm-cli-v${VERSION}" >> $GITHUB_OUTPUT build-binaries: strategy: matrix: include: - target: bun-linux-x64 ext: "" binary_name: cua-linux-x64 - target: bun-darwin-x64 ext: "" binary_name: cua-darwin-x64 - target: bun-darwin-arm64 ext: "" binary_name: cua-darwin-arm64 - target: bun-windows-x64 ext: ".exe" binary_name: cua-windows-x64 runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - 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: Build binary working-directory: ./libs/typescript/cua-cli run: | bun build --compile --minify --sourcemap --target=${{ matrix.target }} index.ts --outfile ${{ matrix.binary_name }}${{ matrix.ext }} mkdir -p ../../../dist mv ${{ matrix.binary_name }}${{ matrix.ext }}* ../../../dist/ - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: cua-binary-${{ matrix.target }} path: dist/ if-no-files-found: error retention-days: 1 publish-npm: needs: prepare uses: ./.github/workflows/ts-reusable-publish.yml with: package_name: "cli" package_dir: "libs/typescript/cua-cli" package_manager: "bun" version: ${{ needs.prepare.outputs.version }} secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} create-release: needs: [prepare, publish-npm, build-binaries] uses: ./.github/workflows/release-github-reusable.yml with: tag_name: ${{ needs.prepare.outputs.tag }} release_name: "cua-cli v${{ needs.prepare.outputs.version }}" module_path: "libs/typescript/cua-cli" attach_artifacts: true body: | ## Installation ### Using install script (recommended) ```bash # For Linux/macOS curl -fsSL https://cua.ai/cli/install.sh | sh # For Windows (PowerShell) irm https://cua.ai/cli/install.ps1 | iex ``` ### Using npm/bun ```bash # Using bun bun add -g @trycua/cli # Or using npm npm install -g @trycua/cli ``` ### From source ```bash git clone -b ${{ needs.prepare.outputs.tag }} https://github.com/trycua/cua.git cd cua/libs/typescript/cua-cli bun install bun link bun link cua-cli ``` ## Release Assets - `cua-darwin-arm64`: macOS (Apple Silicon) - `cua-darwin-x64`: macOS (Intel) - `cua-linux-x64`: Linux (x86_64) - `cua-windows-x64.exe`: Windows (x86_64)