Repository navigation
163 lines (143 loc) · 4.55 KB
/
Copy pathcd-ts-cli.yml
File metadata and controls
163 lines (143 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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)