466 lines
14 KiB
YAML
466 lines
14 KiB
YAML
name: Build Release Artifacts
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build-python-packages:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- name: hindsight-all
|
|
path: hindsight
|
|
- name: hindsight-api
|
|
path: hindsight-api
|
|
- name: hindsight-client
|
|
path: hindsight-clients/python
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
with:
|
|
enable-cache: true
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: ".python-version"
|
|
|
|
- name: Build ${{ matrix.name }} package
|
|
working-directory: ./${{ matrix.path }}
|
|
run: uv build
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: python-${{ matrix.name }}-dist
|
|
path: ${{ matrix.path }}/dist/*
|
|
retention-days: 30
|
|
|
|
build-typescript-client:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install dependencies
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm ci
|
|
|
|
- name: Build TypeScript client
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm run build
|
|
|
|
- name: Pack npm package
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm pack
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: typescript-client-dist
|
|
path: hindsight-clients/typescript/*.tgz
|
|
retention-days: 30
|
|
|
|
build-rust-cli:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact_name: hindsight
|
|
asset_name: hindsight-linux-amd64
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
artifact_name: hindsight
|
|
asset_name: hindsight-darwin-amd64
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact_name: hindsight
|
|
asset_name: hindsight-darwin-arm64
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Cache cargo build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: hindsight-cli/target
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build
|
|
working-directory: hindsight-cli
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Prepare artifact
|
|
run: |
|
|
mkdir -p artifacts
|
|
cp hindsight-cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }} artifacts/${{ matrix.asset_name }}
|
|
chmod +x artifacts/${{ matrix.asset_name }}
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rust-cli-${{ matrix.asset_name }}
|
|
path: artifacts/${{ matrix.asset_name }}
|
|
retention-days: 30
|
|
|
|
build-docker-images:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
# All images use the same Dockerfile with different --target
|
|
- target: api-only
|
|
image_name: hindsight-api
|
|
- target: cp-only
|
|
image_name: hindsight-control-plane
|
|
- target: standalone
|
|
image_name: hindsight
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Free Disk Space
|
|
uses: jlumbroso/free-disk-space@main
|
|
with:
|
|
tool-cache: false
|
|
android: true
|
|
dotnet: true
|
|
haskell: true
|
|
large-packages: true
|
|
docker-images: true
|
|
swap-storage: true
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract version from tag
|
|
id: get_version
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}
|
|
tags: |
|
|
type=semver,pattern={{version}},value=${{ steps.get_version.outputs.VERSION }}
|
|
type=semver,pattern={{major}}.{{minor}},value=${{ steps.get_version.outputs.VERSION }}
|
|
type=semver,pattern={{major}},value=${{ steps.get_version.outputs.VERSION }}
|
|
type=raw,value=latest
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/standalone/Dockerfile
|
|
target: ${{ matrix.target }}
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
package-helm-chart:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Helm
|
|
uses: azure/setup-helm@v4
|
|
with:
|
|
version: 'latest'
|
|
|
|
- name: Lint Helm chart
|
|
run: |
|
|
helm lint helm/hindsight
|
|
|
|
- name: Package Helm chart
|
|
run: |
|
|
helm package helm/hindsight --destination ./helm-packages
|
|
|
|
- name: Upload Helm chart artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: helm-chart
|
|
path: helm-packages/*.tgz
|
|
retention-days: 30
|
|
|
|
publish-python-packages:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-python-packages]
|
|
environment: pypi
|
|
strategy:
|
|
max-parallel: 1
|
|
matrix:
|
|
include:
|
|
# Order matters: client and api first, then hindsight-all (which depends on them)
|
|
- name: hindsight-client
|
|
- name: hindsight-api
|
|
- name: hindsight-all
|
|
|
|
steps:
|
|
- name: Download ${{ matrix.name }}
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: python-${{ matrix.name }}-dist
|
|
path: ./dist
|
|
|
|
- name: Publish ${{ matrix.name }} to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
packages-dir: ./dist
|
|
skip-existing: true
|
|
|
|
publish-npm-package:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-typescript-client]
|
|
environment: npm
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install dependencies
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm ci
|
|
|
|
- name: Build TypeScript client
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm run build
|
|
|
|
- name: Publish to npm
|
|
working-directory: ./hindsight-clients/typescript
|
|
run: npm publish --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
create-github-release:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-python-packages, build-typescript-client, build-rust-cli, build-docker-images, package-helm-chart]
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Extract version from tag
|
|
id: get_version
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download hindsight-all
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: python-hindsight-all-dist
|
|
path: ./artifacts/python-hindsight-all
|
|
|
|
- name: Download hindsight-api
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: python-hindsight-api-dist
|
|
path: ./artifacts/python-hindsight-api
|
|
|
|
- name: Download hindsight-client
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: python-hindsight-client-dist
|
|
path: ./artifacts/python-hindsight-client
|
|
|
|
- name: Download TypeScript Client
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: typescript-client-dist
|
|
path: ./artifacts/typescript-client
|
|
|
|
- name: Download Rust CLI (Linux)
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rust-cli-hindsight-linux-amd64
|
|
path: ./artifacts/rust-cli-hindsight-linux-amd64
|
|
|
|
- name: Download Rust CLI (macOS Intel)
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rust-cli-hindsight-darwin-amd64
|
|
path: ./artifacts/rust-cli-hindsight-darwin-amd64
|
|
|
|
- name: Download Rust CLI (macOS ARM)
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rust-cli-hindsight-darwin-arm64
|
|
path: ./artifacts/rust-cli-hindsight-darwin-arm64
|
|
|
|
- name: Download Helm chart
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: helm-chart
|
|
path: ./artifacts/helm-chart
|
|
|
|
- name: Prepare release assets
|
|
run: |
|
|
mkdir -p release-assets
|
|
# Python packages
|
|
cp artifacts/python-hindsight-all/* release-assets/
|
|
cp artifacts/python-hindsight-api/* release-assets/
|
|
cp artifacts/python-hindsight-client/* release-assets/
|
|
# TypeScript Client
|
|
cp artifacts/typescript-client/*.tgz release-assets/
|
|
# Rust CLI binaries
|
|
cp artifacts/rust-cli-hindsight-linux-amd64/hindsight-linux-amd64 release-assets/
|
|
cp artifacts/rust-cli-hindsight-darwin-amd64/hindsight-darwin-amd64 release-assets/
|
|
cp artifacts/rust-cli-hindsight-darwin-arm64/hindsight-darwin-arm64 release-assets/
|
|
# Helm chart
|
|
cp artifacts/helm-chart/*.tgz release-assets/
|
|
|
|
- name: Generate release notes
|
|
id: release_notes
|
|
run: |
|
|
cat << 'EOF' > release-notes.md
|
|
# Hindsight v${{ steps.get_version.outputs.VERSION }}
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
docker run -p 8888:8888 -p 9999:9999 \
|
|
-e HINDSIGHT_API_LLM_PROVIDER=openai \
|
|
-e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
|
|
-e HINDSIGHT_API_LLM_MODEL=gpt-4o-mini \
|
|
ghcr.io/${{ github.repository_owner }}/hindsight:${{ steps.get_version.outputs.VERSION }}
|
|
```
|
|
|
|
## 📦 Release Artifacts
|
|
|
|
### Docker Images
|
|
- `ghcr.io/${{ github.repository_owner }}/hindsight:${{ steps.get_version.outputs.VERSION }}` - **Standalone all-in-one** (recommended)
|
|
- `ghcr.io/${{ github.repository_owner }}/hindsight-api:${{ steps.get_version.outputs.VERSION }}` - API server only
|
|
- `ghcr.io/${{ github.repository_owner }}/hindsight-control-plane:${{ steps.get_version.outputs.VERSION }}` - Web UI only
|
|
|
|
### Python Packages
|
|
- `hindsight-all` - All-in-one package (includes API + client)
|
|
- `hindsight-api` - API server
|
|
- `hindsight-client` - Client library
|
|
|
|
### TypeScript/JavaScript
|
|
- `@hindsight/client` - TypeScript SDK
|
|
|
|
### CLI Binaries
|
|
- `hindsight-linux-amd64` - Linux x86_64
|
|
- `hindsight-darwin-amd64` - macOS Intel
|
|
- `hindsight-darwin-arm64` - macOS Apple Silicon
|
|
|
|
### Helm Chart
|
|
- `hindsight-${{ steps.get_version.outputs.VERSION }}.tgz`
|
|
|
|
## 🚀 Installation
|
|
|
|
### Python
|
|
```bash
|
|
# All-in-one (recommended)
|
|
pip install hindsight-all==${{ steps.get_version.outputs.VERSION }}
|
|
|
|
# Or install components separately
|
|
pip install hindsight-api==${{ steps.get_version.outputs.VERSION }}
|
|
pip install hindsight-client==${{ steps.get_version.outputs.VERSION }}
|
|
```
|
|
|
|
### TypeScript/JavaScript
|
|
```bash
|
|
npm install @hindsight/client@${{ steps.get_version.outputs.VERSION }}
|
|
```
|
|
|
|
### CLI
|
|
```bash
|
|
# macOS (Apple Silicon)
|
|
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/hindsight-darwin-arm64 -o hindsight
|
|
chmod +x hindsight
|
|
sudo mv hindsight /usr/local/bin/
|
|
|
|
# macOS (Intel)
|
|
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/hindsight-darwin-amd64 -o hindsight
|
|
chmod +x hindsight
|
|
sudo mv hindsight /usr/local/bin/
|
|
|
|
# Linux
|
|
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/hindsight-linux-amd64 -o hindsight
|
|
chmod +x hindsight
|
|
sudo mv hindsight /usr/local/bin/
|
|
```
|
|
|
|
### Helm (Kubernetes)
|
|
```bash
|
|
helm install hindsight oci://ghcr.io/${{ github.repository_owner }}/charts/hindsight --version ${{ steps.get_version.outputs.VERSION }}
|
|
```
|
|
EOF
|
|
cat release-notes.md
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: release-assets/*
|
|
body_path: release-notes.md
|
|
draft: false
|
|
prerelease: false
|
|
generate_release_notes: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create release summary
|
|
run: |
|
|
echo "# Release v${{ steps.get_version.outputs.VERSION }} Published Successfully" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "## 📦 Components" >> $GITHUB_STEP_SUMMARY
|
|
echo "- ✅ Python packages (hindsight-all, hindsight-api, hindsight-client)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- ✅ TypeScript Client (@hindsight/client)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- ✅ Rust CLI (Linux amd64, macOS amd64, macOS arm64)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- ✅ Docker images (standalone, API, Control Plane)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- ✅ Helm chart" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "🎉 Release is now available at: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
|