feat: add gh release creation to NPM workflows

This commit is contained in:
synacktra.work@gmail.com
2025-12-31 22:28:02 +05:30
parent cdd6eac0f6
commit b8f69a831f
3 changed files with 147 additions and 110 deletions
+63 -106
View File
@@ -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)
+42 -2
View File
@@ -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
```
+42 -2
View File
@@ -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
```