Skip to content

Commit 98510d6

Browse files
committed
feat(release): add release workflow for OpenCode with LiteLLM support
- Add GitHub Actions workflow for AI CodeSpark releases - Build CLI binaries for Linux and Windows x64 - Build Windows desktop application with Tauri - Build and publish Docker images to GHCR - Add Dockerfile_litellm for Ubuntu-based container deployment - Install OpenCode CLI from tarball - Configure health checks and non-root user - Expose port 3000 for service access - Add README_litellm.md with detailed usage guide - Installation instructions for CLI, desktop, and Docker - Configuration examples for LiteLLM and Ollama integration - Docker Compose setup and custom image building - Troubleshooting section for common issues - Add opencode.jsonc example configuration - LiteLLM provider setup with OpenAI-compatible SDK - Model configuration for Ollama Kimi K2
1 parent 4299450 commit 98510d6

File tree

4 files changed

+595
-0
lines changed

4 files changed

+595
-0
lines changed
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
name: ai-codespark-release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
permissions:
9+
id-token: write
10+
contents: write
11+
packages: write
12+
13+
jobs:
14+
build-cli-linux:
15+
runs-on: ubuntu-latest
16+
if: github.repository == 'ai-codespark/opencode'
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- run: git fetch --force --tags
23+
24+
- uses: ./.github/actions/setup-bun
25+
26+
- name: Set version
27+
run: |
28+
VERSION="${{ github.event.release.tag_name }}"
29+
VERSION="${VERSION#v}"
30+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
31+
echo "OPENCODE_VERSION=$VERSION" >> $GITHUB_ENV
32+
echo "OPENCODE_CHANNEL=latest" >> $GITHUB_ENV
33+
34+
- name: Update package versions
35+
run: |
36+
find . -name "package.json" -not -path "*/node_modules/*" -not -path "*/dist/*" -exec sed -i 's/"version":[[:space:]]*"[^"]*"/"version": "'"$RELEASE_VERSION"'"/' {} \;
37+
38+
- name: Install dependencies
39+
run: bun install
40+
41+
- name: Build OpenCode CLI (linux-x64)
42+
working-directory: packages/opencode
43+
run: |
44+
bun ./script/build.ts --single
45+
cd dist/opencode-linux-x64/bin
46+
tar -czf ../../../opencode-linux-x64.tar.gz *
47+
cd ../../..
48+
echo "Build completed, tarball created"
49+
ls -lh opencode-linux-x64.tar.gz
50+
51+
- name: Upload Release Asset
52+
uses: actions/upload-release-asset@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.AI_CODESPARK_TOKEN }}
55+
with:
56+
upload_url: ${{ github.event.release.upload_url }}
57+
asset_path: packages/opencode/opencode-linux-x64.tar.gz
58+
asset_name: opencode-linux-x64.tar.gz
59+
asset_content_type: application/gzip
60+
61+
- name: Upload artifact
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: opencode-cli-linux-x64
65+
path: packages/opencode/opencode-linux-x64.tar.gz
66+
67+
build-cli-windows:
68+
runs-on: windows-latest
69+
if: github.repository == 'ai-codespark/opencode'
70+
steps:
71+
- uses: actions/checkout@v3
72+
with:
73+
fetch-depth: 0
74+
75+
- run: git fetch --force --tags
76+
77+
- uses: ./.github/actions/setup-bun
78+
79+
- name: Set version
80+
shell: bash
81+
run: |
82+
VERSION="${{ github.event.release.tag_name }}"
83+
VERSION="${VERSION#v}"
84+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
85+
echo "OPENCODE_VERSION=$VERSION" >> $GITHUB_ENV
86+
echo "OPENCODE_CHANNEL=latest" >> $GITHUB_ENV
87+
88+
- name: Update package versions
89+
shell: bash
90+
run: |
91+
find . -name "package.json" -not -path "*/node_modules/*" -not -path "*/dist/*" -exec sed -i 's/"version":[[:space:]]*"[^"]*"/"version": "'"$RELEASE_VERSION"'"/' {} \;
92+
93+
- name: Install dependencies
94+
run: bun install
95+
96+
- name: Build OpenCode CLI (windows-x64)
97+
working-directory: packages/opencode
98+
shell: bash
99+
run: |
100+
bun ./script/build.ts --single
101+
cd dist/opencode-windows-x64/bin
102+
7z a -tzip ../../../opencode-windows-x64.zip *
103+
cd ../../..
104+
echo "Build completed, zip created"
105+
ls -lh opencode-windows-x64.zip
106+
107+
- name: Upload Release Asset
108+
uses: actions/upload-release-asset@v1
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.AI_CODESPARK_TOKEN }}
111+
with:
112+
upload_url: ${{ github.event.release.upload_url }}
113+
asset_path: packages/opencode/opencode-windows-x64.zip
114+
asset_name: opencode-windows-x64.zip
115+
asset_content_type: application/zip
116+
117+
- name: Upload artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: opencode-cli-windows-x64
121+
path: packages/opencode/opencode-windows-x64.zip
122+
123+
build-desktop-windows:
124+
runs-on: windows-latest
125+
if: github.repository == 'ai-codespark/opencode'
126+
needs: build-cli-windows
127+
steps:
128+
- uses: actions/checkout@v3
129+
with:
130+
fetch-depth: 0
131+
132+
- run: git fetch --force --tags
133+
134+
- uses: ./.github/actions/setup-bun
135+
136+
- name: Install Rust
137+
uses: actions-rust-lang/setup-rust-toolchain@v1
138+
with:
139+
toolchain: stable
140+
141+
- name: Set version
142+
shell: bash
143+
run: |
144+
VERSION="${{ github.event.release.tag_name }}"
145+
VERSION="${VERSION#v}"
146+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
147+
echo "OPENCODE_VERSION=$VERSION" >> $GITHUB_ENV
148+
echo "OPENCODE_CHANNEL=latest" >> $GITHUB_ENV
149+
150+
- name: Update package versions
151+
shell: bash
152+
run: |
153+
find . -name "package.json" -not -path "*/node_modules/*" -not -path "*/dist/*" -exec sed -i 's/"version":[[:space:]]*"[^"]*"/"version": "'"$RELEASE_VERSION"'"/' {} \;
154+
155+
- name: Install dependencies
156+
run: bun install
157+
158+
- name: Download CLI artifact
159+
uses: actions/download-artifact@v4
160+
with:
161+
name: opencode-cli-windows-x64
162+
path: packages/desktop/src-tauri/target/opencode-binaries
163+
164+
- name: Prepare CLI binary for desktop
165+
working-directory: packages/desktop
166+
shell: bash
167+
run: |
168+
mkdir -p src-tauri/sidecars
169+
cd src-tauri/target/opencode-binaries
170+
unzip opencode-windows-x64.zip -d extracted
171+
cp extracted/opencode.exe ../../sidecars/opencode-cli-x86_64-pc-windows-msvc.exe
172+
cd ../../..
173+
ls -lh src-tauri/sidecars/
174+
175+
- name: Build desktop app
176+
working-directory: packages/desktop
177+
env:
178+
RUSTFLAGS: "-A dead_code"
179+
run: |
180+
bun run build
181+
bun tauri build --bundles nsis
182+
183+
- name: Find and rename NSIS installer
184+
working-directory: packages/desktop/src-tauri/target/release/bundle/nsis
185+
shell: bash
186+
run: |
187+
INSTALLER=$(ls *.exe | head -n 1)
188+
if [ -f "$INSTALLER" ]; then
189+
mv "$INSTALLER" "../../../../../opencode-desktop-windows-x64.exe"
190+
echo "Renamed $INSTALLER to opencode-desktop-windows-x64.exe"
191+
fi
192+
193+
- name: Upload Release Asset
194+
uses: actions/upload-release-asset@v1
195+
env:
196+
GITHUB_TOKEN: ${{ secrets.AI_CODESPARK_TOKEN }}
197+
with:
198+
upload_url: ${{ github.event.release.upload_url }}
199+
asset_path: packages/desktop/opencode-desktop-windows-x64.exe
200+
asset_name: opencode-desktop-windows-x64.exe
201+
asset_content_type: application/octet-stream
202+
203+
- name: Upload artifact
204+
uses: actions/upload-artifact@v4
205+
with:
206+
name: opencode-desktop-windows-x64
207+
path: packages/desktop/opencode-desktop-windows-x64.exe
208+
209+
build-docker:
210+
runs-on: ubuntu-latest
211+
if: github.repository == 'ai-codespark/opencode'
212+
needs: build-cli-linux
213+
steps:
214+
- uses: actions/checkout@v3
215+
with:
216+
fetch-depth: 0
217+
218+
- run: git fetch --force --tags
219+
220+
- name: Set up Docker Buildx
221+
uses: docker/setup-buildx-action@v3
222+
223+
- name: Log in to GitHub Container Registry
224+
uses: docker/login-action@v3
225+
with:
226+
registry: ghcr.io
227+
username: ${{ github.actor }}
228+
password: ${{ secrets.AI_CODESPARK_TOKEN }}
229+
230+
- name: Set version
231+
run: |
232+
VERSION="${{ github.event.release.tag_name }}"
233+
VERSION="${VERSION#v}"
234+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
235+
236+
- name: Download CLI artifact
237+
uses: actions/download-artifact@v4
238+
with:
239+
name: opencode-cli-linux-x64
240+
path: .
241+
242+
- name: Build and push Docker image
243+
uses: docker/build-push-action@v5
244+
with:
245+
context: .
246+
file: ./Dockerfile_litellm
247+
push: true
248+
platforms: linux/amd64
249+
build-args: |
250+
OPENCODE_VERSION=${{ env.RELEASE_VERSION }}
251+
tags: |
252+
ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }}
253+
ghcr.io/${{ github.repository }}:latest
254+
cache-from: type=gha
255+
cache-to: type=gha,mode=max

Dockerfile_litellm

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM ubuntu:24.04
2+
3+
LABEL maintainer="AI CodeSpark <support@ai-codespark.com>"
4+
LABEL description="OpenCode - AI-powered code intelligence platform running on Ubuntu"
5+
6+
# Install system dependencies
7+
RUN apt-get update && apt-get install -y \
8+
curl \
9+
wget \
10+
ca-certificates \
11+
unzip \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Set working directory
15+
WORKDIR /app
16+
17+
# Copy the opencode-linux-x64 tarball
18+
ARG OPENCODE_VERSION
19+
COPY opencode-linux-x64.tar.gz /tmp/opencode-linux-x64.tar.gz
20+
21+
# Extract and install OpenCode
22+
RUN mkdir -p /usr/local/opencode && \
23+
tar -xzf /tmp/opencode-linux-x64.tar.gz -C /usr/local/opencode && \
24+
rm /tmp/opencode-linux-x64.tar.gz && \
25+
ln -s /usr/local/opencode/opencode /usr/local/bin/opencode && \
26+
chmod +x /usr/local/opencode/opencode
27+
28+
# Set environment variables
29+
ENV OPENCODE_VERSION=${OPENCODE_VERSION}
30+
ENV OPENCODE_CHANNEL=latest
31+
ENV PATH="/usr/local/opencode:${PATH}"
32+
33+
# Create a non-root user for running OpenCode
34+
RUN useradd -m -s /bin/bash opencode && \
35+
chown -R opencode:opencode /app
36+
37+
USER opencode
38+
39+
# Expose default port (if applicable)
40+
EXPOSE 3000
41+
42+
# Health check
43+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
44+
CMD opencode --version || exit 1
45+
46+
# Default command
47+
CMD ["opencode", "start"]

0 commit comments

Comments
 (0)