From b8f69a831f556bbc67eabb7a8a974396c5abc5fb Mon Sep 17 00:00:00 2001 From: "synacktra.work@gmail.com" Date: Wed, 31 Dec 2025 22:28:02 +0530 Subject: [PATCH] feat: add gh release creation to NPM workflows --- .github/workflows/npm-publish-cli.yml | 169 ++++++++------------- .github/workflows/npm-publish-computer.yml | 44 +++++- .github/workflows/npm-publish-core.yml | 44 +++++- 3 files changed, 147 insertions(+), 110 deletions(-) diff --git a/.github/workflows/npm-publish-cli.yml b/.github/workflows/npm-publish-cli.yml index 90b5fc02..73cef71a 100644 --- a/.github/workflows/npm-publish-cli.yml +++ b/.github/workflows/npm-publish-cli.yml @@ -21,6 +21,32 @@ permissions: 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 [ -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=cua-v${VERSION}" >> $GITHUB_OUTPUT + build-binaries: strategy: matrix: @@ -71,124 +97,55 @@ jobs: retention-days: 1 publish-npm: + needs: prepare 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 || '' }} + version: ${{ needs.prepare.outputs.version }} secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} create-release: - needs: [build-binaries, publish-npm] - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + needs: prepare + uses: ./.github/workflows/github-release-reusable.yml + with: + tag_name: ${{ needs.prepare.outputs.tag }} + release_name: "cua-cli v${{ needs.prepare.outputs.version }}" + attach_artifacts: true + body: | + ## Installation - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest + ### Using install script (recommended) + ```bash + # For Linux/macOS + curl -fsSL https://cua.ai/cli/install.sh | sh - - name: Get version - id: version - run: | - VERSION=$(bun -p "require('./libs/typescript/cua-cli/package.json').version") - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "tag=cua-v${VERSION}" >> $GITHUB_OUTPUT + # For Windows (PowerShell) + irm https://cua.ai/cli/install.ps1 | iex + ``` - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: dist - merge-multiple: true + ### Using npm/bun + ```bash + # Using bun + bun add -g @trycua/cli - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.version.outputs.tag }} - release_name: cua-cli v${{ steps.version.outputs.version }} - body: | - # cua-cli v${{ steps.version.outputs.version }} + # Or using npm + npm install -g @trycua/cli + ``` - ## Installation + ### 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 + ``` - ### 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 ${{ steps.version.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) - draft: false - prerelease: false - - - name: Upload Linux Binary - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/cua-linux-x64 - asset_name: cua-linux-x64 - asset_content_type: application/octet-stream - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload macOS Intel Binary - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/cua-darwin-x64 - asset_name: cua-darwin-x64 - asset_content_type: application/octet-stream - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload macOS Apple Silicon Binary - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/cua-darwin-arm64 - asset_name: cua-darwin-arm64 - asset_content_type: application/octet-stream - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Windows Binary - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/cua-windows-x64.exe - asset_name: cua-windows-x64.exe - asset_content_type: application/octet-stream - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ## 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) diff --git a/.github/workflows/npm-publish-computer.yml b/.github/workflows/npm-publish-computer.yml index 3a26e366..7aff565c 100644 --- a/.github/workflows/npm-publish-computer.yml +++ b/.github/workflows/npm-publish-computer.yml @@ -19,15 +19,55 @@ on: permissions: id-token: write - contents: read + contents: 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 [ -n "${{ github.event.inputs.version }}" ]; then + VERSION="${{ github.event.inputs.version }}" + else + # Read from package.json + VERSION=$(node -p "require('./libs/typescript/computer/package.json').version") + fi + + echo "Computer version: $VERSION" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "tag=npm-computer-v${VERSION}" >> $GITHUB_OUTPUT + publish: + needs: prepare 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 || '' }} + version: ${{ needs.prepare.outputs.version }} secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + create-release: + needs: prepare + uses: ./.github/workflows/github-release-reusable.yml + with: + tag_name: ${{ needs.prepare.outputs.tag }} + release_name: "@trycua/computer v${{ needs.prepare.outputs.version }}" + body: | + ## Installation + + ```bash + npm install @trycua/computer + ``` diff --git a/.github/workflows/npm-publish-core.yml b/.github/workflows/npm-publish-core.yml index 98e163a4..f7834013 100644 --- a/.github/workflows/npm-publish-core.yml +++ b/.github/workflows/npm-publish-core.yml @@ -19,15 +19,55 @@ on: permissions: id-token: write - contents: read + contents: 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 [ -n "${{ github.event.inputs.version }}" ]; then + VERSION="${{ github.event.inputs.version }}" + else + # Read from package.json + VERSION=$(node -p "require('./libs/typescript/core/package.json').version") + fi + + echo "Core version: $VERSION" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "tag=npm-core-v${VERSION}" >> $GITHUB_OUTPUT + publish: + needs: prepare 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 || '' }} + version: ${{ needs.prepare.outputs.version }} secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + create-release: + needs: prepare + uses: ./.github/workflows/github-release-reusable.yml + with: + tag_name: ${{ needs.prepare.outputs.tag }} + release_name: "@trycua/core v${{ needs.prepare.outputs.version }}" + body: | + ## Installation + + ```bash + npm install @trycua/core + ```