# ReleaseHub Self-Hosting

Deploy ReleaseHub on your own infrastructure for complete control over your release management.

## Requirements

- **PHP 8.3+** with common extensions
- **Composer** - PHP dependency manager
- **SQLite or MySQL** - Database backend

## Installation

### 1. Clone and Install Dependencies

```bash
cd releasehub
composer install
```

### 2. Environment Setup

```bash
cp .env.example .env
```

Edit `.env` with your configuration:

```env
APP_NAME=ReleaseHub
APP_URL=http://localhost:8000

# Database - SQLite (default) or MySQL
DB_CONNECTION=sqlite

# JWT Authentication (generate a secure random key)
JWT_SECRET=your-jwt-secret-key-here

# File Storage: local or s3
FILESYSTEM_DISK=local
```

See `.env.example` for all available options including S3 storage, email, and rate limiting.

### 3. Run Migrations

```bash
php artisan migrate
```

### 4. Run Setup Command

```bash
php artisan releasehub:setup
```

This interactive wizard will:
- Ask for admin credentials (name, email, password)
- Set up default platforms (Android, iOS, Windows, macOS, Linux, Web)
- Create channel presets

### 5. Start Development Server

```bash
php -S localhost:8000 -t public
```

## Storage Configuration

### Local Storage (Default)

```env
FILESYSTEM_DISK=local
```

Files stored in `storage/app/releases/`

### S3-Compatible Storage

```env
FILESYSTEM_DISK=s3
AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=your-bucket
AWS_ENDPOINT=https://s3.amazonaws.com
```

## Version Comparison

Per-project setting for how versions are compared:

- **build_first**: Compare build numbers first, then semver (recommended for mobile apps)
- **semver_only**: Pure semantic versioning comparison

## Features

### Core Features

- **Multi-Platform Support**: APK, AAB, EXE, MSI, DMG, AppImage, DEB, ZIP, TAR.GZ
- **Chunked Uploads**: Multipart uploads to bypass PHP limits for large files
- **Multiple Upload Methods**: Web UI, API, SFTP + API registration
- **Release Channels**: Custom channels per project (Stable, Beta, Alpha, etc.)
- **Version Comparison**: Configurable (build number first OR semver only)
- **Architecture Detection**: Auto-detect from filename + manual override + universal builds
- **Changelogs**: Full Markdown support
- **Force Updates**: Per-version flag for critical updates
- **Draft Versions**: Optional draft/publish workflow per project
- **File Retention**: Configurable max versions per project
- **Checksums**: Optional MD5/SHA256 verification

### Security & Access Control

- **JWT Authentication**: Secure admin panel and API access
- **API Keys**: Multiple keys per project with granular permissions
- **Download Auth Options**:
  - Public (no auth)
  - API Key required
  - Password protected
  - Access codes (single/multi-use)
  - Invite links with expiry
- **Rate Limiting**: Tiered by auth type
- **Audit Logging**: All admin actions logged
- **Signed URLs**: Time-limited download links

### User Interface

- **Admin Panel**: Full-featured dashboard with Tailwind CSS
- **Public Portal**: Project listings with search and platform filtering
- **Dark Mode**: Toggle support across all interfaces
- **Responsive Design**: Mobile-friendly layouts

### Additional Features

- **Webhooks**: Outgoing webhooks for release events
- **Basic Analytics**: Download counts per file
- **Branding**: Customizable logo, name, and primary color

## Console Commands

### Database Migrations

```bash
php artisan migrate
```

### Initial Setup

Creates admin user, platforms, channel presets:

```bash
php artisan releasehub:setup
```

### Cleanup Expired Uploads

Remove expired upload sessions and temp files:

```bash
php artisan releasehub:cleanup-uploads
```

### Cleanup Old Versions

Remove old versions based on project retention settings:

```bash
php artisan releasehub:cleanup-versions
```

## Web Routes

| Route | Description |
|-------|-------------|
| `/` | Public portal - project listings |
| `/project/{slug}` | Public project detail page |
| `/project/{slug}/latest` | Redirect to latest release APK |
| `/project/{slug}/{arch}/latest` | Redirect to latest release APK for specific architecture (arm64-v8a, armeabi-v7a, x86_64) |
| `/invite/{token}` | Invite link landing page |
| `/admin/login` | Admin login page |
| `/admin` | Admin dashboard |
| `/admin/projects` | Project management |
| `/admin/platforms` | Platform management |
| `/admin/users` | User management |
| `/admin/audit-logs` | Audit logs |
| `/admin/settings` | Settings |
| `/health` | Health check endpoint |

## Directory Structure

```
releasehub/
├── app/
│   ├── Console/Commands/       # Artisan commands
│   │   ├── CleanupExpiredUploads.php
│   │   ├── CleanupOldVersions.php
│   │   └── SetupCommand.php
│   ├── Http/
│   │   ├── Controllers/
│   │   │   ├── Api/            # API controllers
│   │   │   │   ├── AuthController.php
│   │   │   │   ├── DownloadController.php
│   │   │   │   ├── PublicController.php
│   │   │   │   ├── UploadController.php
│   │   │   │   └── VersionCheckController.php
│   │   │   ├── Admin/          # Admin API + page controllers
│   │   │   └── Public/         # Public portal controllers
│   │   └── Middleware/         # Auth, rate limiting, etc.
│   ├── Models/                 # Eloquent models
│   │   ├── User.php
│   │   ├── Project.php
│   │   ├── Version.php
│   │   ├── ReleaseFile.php
│   │   ├── ReleaseChannel.php
│   │   ├── ProjectApiKey.php
│   │   ├── AccessCode.php
│   │   ├── InviteLink.php
│   │   ├── Webhook.php
│   │   └── ...
│   └── Services/               # Business logic
│       ├── ApiKeyService.php
│       ├── Storage/
│       │   └── StorageManager.php
│       ├── Upload/
│       │   └── ChunkedUploadService.php
│       └── Version/
│           └── VersionComparator.php
├── config/                     # Configuration files
├── database/
│   └── migrations/             # Database migrations
├── public/                     # Web root
│   └── logo.svg                # Default logo
├── resources/views/
│   ├── layouts/
│   │   ├── app.blade.php       # Base layout
│   │   └── admin.blade.php     # Admin layout
│   ├── admin/                  # Admin panel views
│   │   ├── login.blade.php
│   │   ├── dashboard.blade.php
│   │   ├── projects.blade.php
│   │   └── ...
│   └── public/                 # Public portal views
│       ├── portal.blade.php
│       └── project.blade.php
├── routes/
│   └── web.php                 # All routes
└── storage/app/
    └── releases/               # Uploaded files (local storage)
```

---

*ReleaseHub - Proprietary software by Version Two s.r.o. Copyright 2026.*
