Skip to content

Implement cross-platform build system with automatic versioning for main branch deployments#4

Merged
streed merged 3 commits intomainfrom
copilot/fix-caaaf750-fced-4d98-af58-2dbcf63cc3e4
Aug 30, 2025
Merged

Implement cross-platform build system with automatic versioning for main branch deployments#4
streed merged 3 commits intomainfrom
copilot/fix-caaaf750-fced-4d98-af58-2dbcf63cc3e4

Conversation

Copy link
Contributor

Copilot AI commented Aug 30, 2025

This PR implements a comprehensive build system that automatically creates cross-platform binaries when code is merged to the main branch, addressing the requirements for Windows, Linux, and macOS builds with semantic versioning.

Key Features

Automatic Version Management

  • VERSION file with semantic versioning starting at 1.0.0
  • Automatic patch increment on every main branch merge (e.g., 1.0.0 → 1.0.1)
  • Version embedding in binaries at build time using Go ldflags
  • Version flags (--version) added to both CLI and server applications
  • Dynamic version display in help text, server startup messages, and health API endpoint

Cross-Platform Build Support

The new GitHub Actions workflow builds binaries for:

  • Linux: AMD64, ARM64
  • macOS: AMD64 (Intel), ARM64 (Apple Silicon)
  • Windows: AMD64

All builds include:

  • Embedded version information
  • Optimized binaries with -ldflags="-s -w"
  • Compressed archives with checksums
  • 30-day artifact retention in GitHub Actions

Build Triggers

  • Main branch only: Builds trigger exclusively on pushes to main, not on PRs
  • Skip CI commits: Version bump commits include [skip ci] to prevent infinite loops
  • Robust permissions: Workflow has appropriate permissions to push version updates back to repository

Developer Experience

Enhanced Makefile with new targets:

make build        # Build for current platform with version
make build-cross  # Build for all platforms (requires cross-compilers)
make version      # Show current version from VERSION file
make clean-dist   # Clean distribution artifacts

Example Usage

# Check version in any binary
./bin/lil-rag --version
# Output: lil-rag version 1.0.1

./bin/lil-rag-server --version  
# Output: lil-rag-server version 1.0.1

# Version shown in help
./bin/lil-rag --help
# Output: LilRag - A simple RAG system with SQLite and Ollama (version 1.0.1)

# Version available via health API
curl http://localhost:8080/api/health
# Output: {"status":"healthy","timestamp":"...","version":"1.0.1"}

Technical Implementation

Minimal Code Changes

  • Added version variable to main packages with build-time injection
  • Updated handlers to accept version parameter instead of hardcoded "1.0.0"
  • Maintained backward compatibility with existing New() constructor
  • Updated tests to work with new versioned constructors

Workflow Design

The GitHub Actions workflow (main-build.yml):

  1. Runs tests to ensure code quality
  2. Increments patch version in VERSION file
  3. Commits version update with [skip ci] flag
  4. Builds cross-platform binaries with embedded version
  5. Creates versioned archives with checksums
  6. Uploads artifacts with build summary

Documentation Updates

  • README: Added development section explaining new build targets and version management
  • CONTRIBUTING: Updated release process to document automatic vs manual releases

Testing

  • ✅ All existing tests pass
  • ✅ Version injection works correctly in cross-compiled binaries
  • ✅ Archive creation and naming follows semantic versioning
  • ✅ CLI and server applications display version information properly
  • ✅ Health API endpoint returns dynamic version

This implementation provides a robust, automated build system that scales with the project while maintaining simplicity for developers.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 30, 2025 05:28
Co-authored-by: streed <805140+streed@users.noreply.github.com>
…workflow

Co-authored-by: streed <805140+streed@users.noreply.github.com>
Copilot AI changed the title [WIP] The build system should build the binsries for windows, linix, and osx. These should also only be built when mergee into main not for PRs. This should also include a VERSION file thag follows semantic versioning thag sbould be incremented for each build. Implement cross-platform build system with automatic versioning for main branch deployments Aug 30, 2025
Copilot AI requested a review from streed August 30, 2025 05:32
@streed streed marked this pull request as ready for review August 30, 2025 05:35
Copilot AI review requested due to automatic review settings August 30, 2025 05:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive cross-platform build system with automatic versioning that triggers on main branch merges. The system automatically increments patch versions, builds binaries for multiple platforms (Linux, macOS, Windows), and embeds version information into the executables.

  • Automatic patch version incrementing on main branch pushes (e.g., 1.0.0 → 1.0.1)
  • Cross-platform binary builds for Linux, macOS, and Windows with embedded version information
  • Version display functionality added to both CLI and server applications

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
VERSION Initial version file containing "1.0.0"
.github/workflows/main-build.yml GitHub Actions workflow for automated builds and version management
cmd/lil-rag/main.go Added version variable and --version flag to CLI
cmd/lil-rag-server/main.go Added version variable, --version flag, and version logging to server
internal/handlers/handlers.go Added version field to Handler struct and versioned constructor
internal/handlers/handlers_test.go Updated tests for new versioned constructor
Makefile Enhanced build targets with version embedding and cross-platform support
README.md Added documentation for version management and cross-platform builds
CONTRIBUTING.md Updated release process documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +58 to +68
- name: Commit version update
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add VERSION
if git diff --staged --quiet; then
echo "No version changes to commit"
else
git commit -m "Bump version to ${{ steps.version.outputs.new }} [skip ci]"
git push
fi
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow will fail on the first run because it attempts to increment a version before any version bump commits exist. The git diff --staged --quiet check will always be false since VERSION is always modified in the previous step, making the conditional logic ineffective.

Copilot uses AI. Check for mistakes.
@echo "All tasks completed successfully!"

build-cross: ## Build binaries for all platforms
@echo "Building cross-platform binaries version $(VERSION)..."
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross-compilation targets assume availability of cross-compilers (aarch64-linux-gnu-gcc, x86_64-w64-mingw32-gcc) without installation steps. This will fail on systems without these cross-compilers installed, making the build-cross target unreliable for local development.

Copilot uses AI. Check for mistakes.
@streed streed merged commit 2516b24 into main Aug 30, 2025
6 of 8 checks passed
@streed streed deleted the copilot/fix-caaaf750-fced-4d98-af58-2dbcf63cc3e4 branch August 30, 2025 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants