From 93895f3a6091a4e4e928930aee988fc1db36d15a Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Tue, 9 Dec 2025 11:43:50 +1100 Subject: [PATCH] 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. --- CHANGELOG.md | 20 ++++++++++++++++++++ README.md | 4 +++- composer.json | 2 +- src/Commands/DeploySharedCommand.php | 19 +++++++++++-------- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa6516..bef3054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/), 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 ### Added diff --git a/README.md b/README.md index c065206..eb137e9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Deploy your Laravel application to Hostinger shared hosting with automated GitHu Install the package via Composer: ```bash -composer require thecodeholic/laravel-hostinger-deploy:^0.4 --dev +composer require thecodeholic/laravel-hostinger-deploy:^0.5 --dev ``` 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. +> **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 diff --git a/composer.json b/composer.json index b738deb..67975c0 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "thecodeholic/laravel-hostinger-deploy", "description": "Laravel package for automated Hostinger deployment with GitHub Actions support", "type": "library", - "version": "0.4.0", + "version": "0.5.0", "license": "MIT", "keywords": [ "laravel", diff --git a/src/Commands/DeploySharedCommand.php b/src/Commands/DeploySharedCommand.php index 414b3f0..d71bd9d 100644 --- a/src/Commands/DeploySharedCommand.php +++ b/src/Commands/DeploySharedCommand.php @@ -351,21 +351,24 @@ class DeploySharedCommand extends BaseHostingerCommand $composerFlags = config('hostinger-deploy.deployment.composer_flags', '--no-dev --optimize-autoloader'); $commands[] = "composer install {$composerFlags}"; - // Copy .env.example to .env - $commands[] = "if [ -f .env.example ]; then cp .env.example .env; fi"; + // Copy .env.example to .env ONLY if .env doesn't exist + $commands[] = "if [ -f .env.example ] && [ ! -f .env ]; then cp .env.example .env; fi"; - // Create symbolic link for Laravel public folder - $commands[] = "if [ -d public ]; then ln -s public public_html; fi"; + // Create symbolic link for Laravel public folder (only if it doesn't exist) + $commands[] = "if [ -d public ] && [ ! -L public_html ] && [ ! -d public_html ]; then ln -s public public_html; fi"; - // Laravel setup - $commands[] = "php artisan key:generate --quiet"; + // Generate app key ONLY if APP_KEY is not set in .env + // 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)) { - $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)) { - $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;