169 lines
4.8 KiB
Bash
Executable file
169 lines
4.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Function to print colored output
|
|
print_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_warn() {
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Check if version is provided
|
|
if [ -z "$1" ]; then
|
|
print_error "Usage: $0 <version>"
|
|
print_info "Example: $0 0.2.0"
|
|
exit 1
|
|
fi
|
|
|
|
VERSION=$1
|
|
|
|
# Validate version format (semantic versioning)
|
|
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
print_error "Invalid version format. Please use semantic versioning (e.g., 0.2.0)"
|
|
exit 1
|
|
fi
|
|
|
|
print_info "Starting release process for version $VERSION"
|
|
|
|
# Check if we're on main branch
|
|
CURRENT_BRANCH=$(git branch --show-current)
|
|
if [ "$CURRENT_BRANCH" != "main" ]; then
|
|
print_warn "You are not on the main branch (current: $CURRENT_BRANCH)"
|
|
read -p "Do you want to continue? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
print_error "Release cancelled"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Check if working directory is clean
|
|
if [[ -n $(git status -s) ]]; then
|
|
print_error "Working directory is not clean. Please commit or stash your changes."
|
|
git status -s
|
|
exit 1
|
|
fi
|
|
|
|
# Check if tag already exists
|
|
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
print_error "Tag v$VERSION already exists"
|
|
exit 1
|
|
fi
|
|
|
|
print_info "Updating version in all components..."
|
|
|
|
# Update Python packages
|
|
PYTHON_PACKAGES=("hindsight-api" "hindsight-dev" "hindsight" "hindsight-integrations/litellm" "hindsight-embed")
|
|
for package in "${PYTHON_PACKAGES[@]}"; do
|
|
PYPROJECT_FILE="$package/pyproject.toml"
|
|
if [ -f "$PYPROJECT_FILE" ]; then
|
|
print_info "Updating $PYPROJECT_FILE"
|
|
sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" "$PYPROJECT_FILE"
|
|
rm "${PYPROJECT_FILE}.bak"
|
|
else
|
|
print_warn "File $PYPROJECT_FILE not found, skipping"
|
|
fi
|
|
done
|
|
|
|
# Update Rust CLI
|
|
CARGO_FILE="hindsight-cli/Cargo.toml"
|
|
if [ -f "$CARGO_FILE" ]; then
|
|
print_info "Updating $CARGO_FILE"
|
|
sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" "$CARGO_FILE"
|
|
rm "${CARGO_FILE}.bak"
|
|
else
|
|
print_warn "File $CARGO_FILE not found, skipping"
|
|
fi
|
|
|
|
# Update Helm chart
|
|
HELM_CHART_FILE="helm/hindsight/Chart.yaml"
|
|
if [ -f "$HELM_CHART_FILE" ]; then
|
|
print_info "Updating $HELM_CHART_FILE"
|
|
sed -i.bak "s/^version: .*/version: $VERSION/" "$HELM_CHART_FILE"
|
|
sed -i.bak "s/^appVersion: .*/appVersion: \"$VERSION\"/" "$HELM_CHART_FILE"
|
|
rm "${HELM_CHART_FILE}.bak"
|
|
else
|
|
print_warn "File $HELM_CHART_FILE not found, skipping"
|
|
fi
|
|
|
|
# Update Control Plane package.json
|
|
CONTROL_PLANE_PKG="hindsight-control-plane/package.json"
|
|
if [ -f "$CONTROL_PLANE_PKG" ]; then
|
|
print_info "Updating $CONTROL_PLANE_PKG"
|
|
sed -i.bak "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$CONTROL_PLANE_PKG"
|
|
rm "${CONTROL_PLANE_PKG}.bak"
|
|
else
|
|
print_warn "File $CONTROL_PLANE_PKG not found, skipping"
|
|
fi
|
|
|
|
# Update Python API client
|
|
PYTHON_CLIENT_PKG="hindsight-clients/python/pyproject.toml"
|
|
if [ -f "$PYTHON_CLIENT_PKG" ]; then
|
|
print_info "Updating $PYTHON_CLIENT_PKG"
|
|
sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" "$PYTHON_CLIENT_PKG"
|
|
rm "${PYTHON_CLIENT_PKG}.bak"
|
|
else
|
|
print_warn "File $PYTHON_CLIENT_PKG not found, skipping"
|
|
fi
|
|
|
|
# Update TypeScript API client
|
|
TYPESCRIPT_CLIENT_PKG="hindsight-clients/typescript/package.json"
|
|
if [ -f "$TYPESCRIPT_CLIENT_PKG" ]; then
|
|
print_info "Updating $TYPESCRIPT_CLIENT_PKG"
|
|
sed -i.bak "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$TYPESCRIPT_CLIENT_PKG"
|
|
rm "${TYPESCRIPT_CLIENT_PKG}.bak"
|
|
else
|
|
print_warn "File $TYPESCRIPT_CLIENT_PKG not found, skipping"
|
|
fi
|
|
|
|
# Show changes
|
|
print_info "Changes to be committed:"
|
|
git diff
|
|
|
|
# Confirm changes
|
|
echo
|
|
read -p "Do you want to commit these changes and create tag v$VERSION? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
print_error "Release cancelled. Rolling back changes..."
|
|
git checkout .
|
|
exit 1
|
|
fi
|
|
|
|
# Commit changes
|
|
print_info "Committing version changes..."
|
|
git add -A
|
|
git commit --no-verify -m "Release v$VERSION
|
|
|
|
- Update version to $VERSION in all components
|
|
- Python packages: hindsight-api, hindsight-dev, hindsight-all, hindsight-litellm, hindsight-embed
|
|
- Python client: hindsight-clients/python
|
|
- TypeScript client: hindsight-clients/typescript
|
|
- Rust CLI: hindsight-cli
|
|
- Control Plane: hindsight-control-plane
|
|
- Helm chart"
|
|
|
|
# Create tag
|
|
print_info "Creating tag v$VERSION..."
|
|
git tag -a "v$VERSION" -m "Release v$VERSION"
|
|
|
|
# Push changes
|
|
print_info "Pushing changes and tag to remote..."
|
|
git push origin "$CURRENT_BRANCH"
|
|
git push origin "v$VERSION"
|
|
|
|
print_info "✅ Release v$VERSION completed successfully!"
|
|
print_info "GitHub Actions will now build the release artifacts."
|
|
print_info "Tag: v$VERSION"
|