-
Notifications
You must be signed in to change notification settings - Fork 0
237 lines (199 loc) · 7.13 KB
/
release.yml
File metadata and controls
237 lines (199 loc) · 7.13 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Build frontend
working-directory: frontend
run: pnpm build
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist
build-server:
name: Build Server (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-13
binary_name: server-darwin-x64
- target: aarch64-apple-darwin
os: macos-latest
binary_name: server-darwin-arm64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary_name: server-linux-x64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
binary_name: server-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Build server
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
cargo build --release --bin server --target ${{ matrix.target }}
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/server dist/${{ matrix.binary_name }}
chmod +x dist/${{ matrix.binary_name }}
gzip -9 dist/${{ matrix.binary_name }}
- name: Upload server artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: dist/${{ matrix.binary_name }}.gz
release:
name: Create Release
needs: [build-frontend, build-server]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
# Frontend
cd artifacts/frontend-dist
zip -r ../../release/frontend.zip .
cd ../..
# Server binaries
cp artifacts/server-darwin-x64/server-darwin-x64.gz release/
cp artifacts/server-darwin-arm64/server-darwin-arm64.gz release/
cp artifacts/server-linux-x64/server-linux-x64.gz release/
cp artifacts/server-linux-arm64/server-linux-arm64.gz release/
ls -la release/
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: OpenCode Studio v${{ steps.version.outputs.version }}
draft: false
prerelease: false
files: |
release/frontend.zip
release/server-darwin-x64.gz
release/server-darwin-arm64.gz
release/server-linux-x64.gz
release/server-linux-arm64.gz
body: |
## OpenCode Studio v${{ steps.version.outputs.version }}
### Installation via npx (Recommended)
```bash
npx opencode-studio
```
### Manual Installation
**Prerequisites:** [OpenCode](https://opencode.ai) must be installed.
**macOS (Apple Silicon)**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.version.outputs.version }}/server-darwin-arm64.gz | gunzip > /usr/local/bin/opencode-studio-server
chmod +x /usr/local/bin/opencode-studio-server
```
**macOS (Intel)**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.version.outputs.version }}/server-darwin-x64.gz | gunzip > /usr/local/bin/opencode-studio-server
chmod +x /usr/local/bin/opencode-studio-server
```
**Linux (x86_64)**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.version.outputs.version }}/server-linux-x64.gz | gunzip > /usr/local/bin/opencode-studio-server
chmod +x /usr/local/bin/opencode-studio-server
```
**Linux (ARM64)**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.version.outputs.version }}/server-linux-arm64.gz | gunzip > /usr/local/bin/opencode-studio-server
chmod +x /usr/local/bin/opencode-studio-server
```
publish-npm:
name: Publish to npm
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: dist/frontend
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Update package.json version
run: |
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}