Release version 0.5.0 with significant improvements for incremental deployments, ensuring user data and configuration files are preserved. Updated deployment commands to be idempotent, added checks for existing configurations, and enhanced the README and CHANGELOG to reflect these changes.

This commit is contained in:
Zura Sekhniashvili
2025-12-09 11:43:50 +11:00
parent 99e2f56e0f
commit 93895f3a60
4 changed files with 35 additions and 10 deletions

View File

@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.5.0] - 2025-01-XX
### Fixed
- Fixed `.env` file being overwritten during incremental deployments
- Fixed app key regeneration breaking user sessions on subsequent deployments
- Fixed storage symlink creation errors when symlink already exists
- Fixed `public_html` symlink creation errors when symlink already exists
### Improved
- Post-deployment commands now run conditionally based on existing state
- `.env` file is only created from `.env.example` if it doesn't already exist
- App key generation only runs if `APP_KEY` is not set in `.env`
- Storage symlink creation only runs if symlink doesn't exist
- Safe for incremental deployments - preserves user data and configuration files
- Migrations now check for `.env` existence before running
### Changed
- Deployment commands are now idempotent - safe to run multiple times without side effects
- First-time deployment behavior unchanged, but subsequent deployments preserve existing configuration
## [0.4.0] - 2025-11-11 ## [0.4.0] - 2025-11-11
### Added ### Added

View File

@@ -7,7 +7,7 @@ Deploy your Laravel application to Hostinger shared hosting with automated GitHu
Install the package via Composer: Install the package via Composer:
```bash ```bash
composer require thecodeholic/laravel-hostinger-deploy:^0.4 --dev composer require thecodeholic/laravel-hostinger-deploy:^0.5 --dev
``` ```
Or install the latest version: Or install the latest version:
@@ -81,6 +81,8 @@ php artisan hostinger:deploy
> **Note:** If `GITHUB_API_TOKEN` is provided (via `.env` or `--token` option), the command will automatically add deploy keys to your GitHub repository. Otherwise, you'll be prompted to add the deploy key manually. > **Note:** If `GITHUB_API_TOKEN` is provided (via `.env` or `--token` option), the command will automatically add deploy keys to your GitHub repository. Otherwise, you'll be prompted to add the deploy key manually.
> **Incremental Deployments:** The command is safe to run multiple times. It uses `git pull` for incremental updates and preserves gitignored files (like `.env`, `storage/`, etc.). Setup commands (like key generation, storage link creation) only run if needed, preventing overwrites of existing configuration.
--- ---
### 2. Create GitHub Actions Workflow File ### 2. Create GitHub Actions Workflow File

View File

@@ -2,7 +2,7 @@
"name": "thecodeholic/laravel-hostinger-deploy", "name": "thecodeholic/laravel-hostinger-deploy",
"description": "Laravel package for automated Hostinger deployment with GitHub Actions support", "description": "Laravel package for automated Hostinger deployment with GitHub Actions support",
"type": "library", "type": "library",
"version": "0.4.0", "version": "0.5.0",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"laravel", "laravel",

View File

@@ -351,21 +351,24 @@ class DeploySharedCommand extends BaseHostingerCommand
$composerFlags = config('hostinger-deploy.deployment.composer_flags', '--no-dev --optimize-autoloader'); $composerFlags = config('hostinger-deploy.deployment.composer_flags', '--no-dev --optimize-autoloader');
$commands[] = "composer install {$composerFlags}"; $commands[] = "composer install {$composerFlags}";
// Copy .env.example to .env // Copy .env.example to .env ONLY if .env doesn't exist
$commands[] = "if [ -f .env.example ]; then cp .env.example .env; fi"; $commands[] = "if [ -f .env.example ] && [ ! -f .env ]; then cp .env.example .env; fi";
// Create symbolic link for Laravel public folder // Create symbolic link for Laravel public folder (only if it doesn't exist)
$commands[] = "if [ -d public ]; then ln -s public public_html; fi"; $commands[] = "if [ -d public ] && [ ! -L public_html ] && [ ! -d public_html ]; then ln -s public public_html; fi";
// Laravel setup // Generate app key ONLY if APP_KEY is not set in .env
$commands[] = "php artisan key:generate --quiet"; // Check if .env exists AND if APP_KEY line exists and is not empty
$commands[] = "if [ -f .env ] && ! grep -q '^APP_KEY=base64:' .env 2>/dev/null && ! grep -q '^APP_KEY=\"base64:' .env 2>/dev/null; then php artisan key:generate --quiet; fi";
// Run migrations only if .env exists (app is configured)
if (config('hostinger-deploy.deployment.run_migrations', true)) { if (config('hostinger-deploy.deployment.run_migrations', true)) {
$commands[] = "echo 'yes' | php artisan migrate --quiet"; $commands[] = "if [ -f .env ]; then echo 'yes' | php artisan migrate --quiet; fi";
} }
// Create storage link only if it doesn't exist
if (config('hostinger-deploy.deployment.run_storage_link', true)) { if (config('hostinger-deploy.deployment.run_storage_link', true)) {
$commands[] = "php artisan storage:link --quiet"; $commands[] = "if [ -d public ] && [ ! -L public/storage ] && [ ! -d public/storage ]; then php artisan storage:link --quiet; fi";
} }
return $commands; return $commands;