Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 47 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,21 @@ name: Build Release Binaries
on:
release:
types: [created, published, edited]
push:
branches: [ main ]
workflow_dispatch:
inputs:
create-artifact:
description: 'Create build artifact'
required: true
type: boolean
default: false

jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: agentapi
asset_name: agentapi-linux-amd64
goarch: amd64
goos: linux
- os: macos-latest
artifact_name: agentapi
asset_name: agentapi-darwin-amd64
goarch: amd64
goos: darwin
- os: macos-latest
artifact_name: agentapi
asset_name: agentapi-darwin-arm64
goarch: arm64
goos: darwin
- os: windows-latest
artifact_name: agentapi.exe
asset_name: agentapi-windows-amd64.exe
goarch: amd64
goos: windows
name: Build Release Binaries
runs-on: depot-ubuntu-22.04-4
if: ${{ github.repository_owner == 'coder' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -40,18 +27,42 @@ jobs:
with:
go-version: 'stable'

- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build -v -o ${{ matrix.artifact_name }} .
- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install Chat Dependencies
run: cd chat && bun install

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
- name: Build and Upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
build_variants=(
"linux amd64 agentapi-linux-amd64"
"darwin amd64 agentapi-darwin-amd64"
"darwin arm64 agentapi-darwin-arm64"
"windows amd64 agentapi-windows-amd64.exe"
)

for variant in "${build_variants[@]}"; do
read -r goos goarch artifact_name <<< "$variant"

echo "Building for GOOS=$goos GOARCH=$goarch..."
GOOS=$goos GOARCH=$goarch BINPATH="out/$artifact_name" make build
done

- name: Upload Build Artifact
if: ${{ inputs.create-artifact }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
name: agentapi-build
path: ${{ github.workspace }}/out
retention-days: 7

- name: Upload Release Assets
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/main' }}
run: gh release upload "$RELEASE_TAG" "$GITHUB_WORKSPACE"/out/* --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || 'preview' }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ output-*.log
snapshot-*.log
snapshot2-*.log
.aider*
schema.yaml
schema.yaml
**/.claude/settings.local.json
out
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CHAT_SOURCES_STAMP = chat/.sources.stamp
CHAT_SOURCES = $(shell find chat \( -path chat/node_modules -o -path chat/out -o -path chat/.next \) -prune -o -not -path chat/.sources.stamp -type f -print)
BINPATH ?= out/agentapi

$(CHAT_SOURCES_STAMP): $(CHAT_SOURCES)
@echo "Chat sources changed. Running build steps..."
cd chat && bun run build
rm -rf lib/httpapi/chat && mkdir -p lib/httpapi/chat && touch lib/httpapi/chat/marker
cp -r chat/out/. lib/httpapi/chat/
touch $@

.PHONY: embed
embed: $(CHAT_SOURCES_STAMP)
@echo "Chat build is up to date."

.PHONY: build
build: embed
go build -o ${BINPATH} main.go
1 change: 1 addition & 0 deletions chat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.sources.stamp
842 changes: 842 additions & 0 deletions chat/bun.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chat/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const nextConfig = {
},

// Configure base path for GitHub Pages (repo/chat)
basePath: isGitHubPages ? `/${repo}/${subPath}` : "",
basePath: isGitHubPages ? `/${repo}/${subPath}` : `/${subPath}`,

// Configure asset prefix for GitHub Pages - helps with static asset loading
assetPrefix: isGitHubPages ? `/${repo}/${subPath}/` : "",
assetPrefix: isGitHubPages ? `/${repo}/${subPath}/` : `/${subPath}/`,

// Configure trailing slashes (recommended for static exports)
trailingSlash: true,
Expand Down
Loading