-
Notifications
You must be signed in to change notification settings - Fork 0
256 lines (212 loc) · 7.5 KB
/
release.yml
File metadata and controls
256 lines (212 loc) · 7.5 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📦 Version: $VERSION"
- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: 3.7.2
- name: Sync documentation
run: dart scripts/sync_docs.dart
continue-on-error: true
- name: Upload synced docs
uses: actions/upload-artifact@v4
with:
name: synced-docs
path: |
ide-plugins/vscode/README.md
npm/README.md
web-ui/README.md
retention-days: 1
build-cli:
name: Build CLI - ${{ matrix.target }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: opencli
asset_name: opencli-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: opencli
asset_name: opencli-macos-arm64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: opencli
asset_name: opencli-linux-x86_64
# TODO: 添加 Linux ARM64 交叉编译支持
# 需要配置 gcc-aarch64-linux-gnu 和正确的链接器
# - os: ubuntu-latest
# target: aarch64-unknown-linux-musl
# artifact_name: opencli
# asset_name: opencli-linux-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: opencli.exe
asset_name: opencli-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools (Linux)
if: contains(matrix.target, 'linux-musl')
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi
- name: Build CLI
working-directory: cli
run: cargo build --release --target ${{ matrix.target }}
- name: Strip binary (Unix)
if: matrix.os != 'windows-latest'
run: strip cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Calculate SHA256
id: sha256
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
SHA256=$(powershell -Command "(Get-FileHash -Path cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }} -Algorithm SHA256).Hash.ToLower()")
else
SHA256=$(shasum -a 256 cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | cut -d' ' -f1)
fi
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
echo "$SHA256 ${{ matrix.asset_name }}" > cli/target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: |
cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
cli/target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256
build-daemon:
name: Build Daemon - ${{ matrix.os }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
asset_name: opencli-daemon-macos
binary_name: opencli-daemon
- os: ubuntu-latest
asset_name: opencli-daemon-linux
binary_name: opencli-daemon
- os: windows-latest
asset_name: opencli-daemon-windows.exe
binary_name: opencli-daemon.exe
steps:
- uses: actions/checkout@v4
- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: 3.7.2
- name: Install dependencies
working-directory: daemon
run: dart pub get
- name: Compile daemon
working-directory: daemon
run: dart compile exe bin/daemon.dart -o ${{ matrix.binary_name }}
- name: Calculate SHA256
id: sha256
shell: bash
working-directory: daemon
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
SHA256=$(powershell -Command "(Get-FileHash -Path ${{ matrix.binary_name }} -Algorithm SHA256).Hash.ToLower()")
else
SHA256=$(shasum -a 256 ${{ matrix.binary_name }} | cut -d' ' -f1)
fi
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
echo "$SHA256 ${{ matrix.asset_name }}" > ${{ matrix.asset_name }}.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: |
daemon/${{ matrix.binary_name }}
daemon/${{ matrix.asset_name }}.sha256
create-release:
name: Create GitHub Release
needs: [prepare, build-cli, build-daemon]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Organize release assets
run: |
mkdir -p release-assets
# Copy all binaries and checksums
find artifacts -type f \( -name "opencli*" -o -name "*.sha256" \) -exec cp {} release-assets/ \;
# List files for verification
ls -lah release-assets/
- name: Generate combined checksums
working-directory: release-assets
run: |
echo "# SHA256 Checksums for OpenCLI v${{ needs.prepare.outputs.version }}" > SHA256SUMS.txt
echo "" >> SHA256SUMS.txt
for file in *.sha256; do
cat "$file" >> SHA256SUMS.txt
done
cat SHA256SUMS.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: v${{ needs.prepare.outputs.version }}
files: release-assets/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(needs.prepare.outputs.version, '-') }}
body: |
## OpenCLI v${{ needs.prepare.outputs.version }}
### Installation
**macOS:**
```bash
brew install opencli/tap/opencli
```
**Windows:**
```powershell
scoop bucket add opencli https://github.com/opencli/scoop-bucket
scoop install opencli
```
**Linux:**
```bash
curl -sSL https://opencli.ai/install.sh | sh
```
**npm:**
```bash
npm install -g @opencli/cli
```
### Download Binaries
Download the appropriate binary for your platform below, or use one of the package managers above.
All binaries are signed and include SHA256 checksums for verification.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}