From 6a278f98e86e76f06ed9d03670028c3bf03df297 Mon Sep 17 00:00:00 2001 From: Diego Lozano Date: Thu, 7 Mar 2024 14:32:58 -0500 Subject: [PATCH] update docs --- changelog.md | 4 + config/app-version.php | 4 +- phpunit.xml | 4 - readme.md | 177 ++++++++++++++++++++++------------------- 4 files changed, 100 insertions(+), 89 deletions(-) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..efb42d5 --- /dev/null +++ b/changelog.md @@ -0,0 +1,4 @@ +# Changelog + +## 2.8.0 (2024-03-07) +- Add auth Basic to view version diff --git a/config/app-version.php b/config/app-version.php index 37a8fe5..6f417dc 100644 --- a/config/app-version.php +++ b/config/app-version.php @@ -49,8 +49,8 @@ 'version' => \PlacetoPay\AppVersion\VersionFile::read(), /** - * Credentials by get /version. + * the credentials to be able to see the deployed version. */ 'username' => env('APP_VERSION_USERNAME', 'admin'), - 'password' => env('APP_VERSION_PASSWORD', 'password'), + 'password' => env('APP_VERSION_PASSWORD', 'Testing123!'), ]; diff --git a/phpunit.xml b/phpunit.xml index 50ebe8c..7773100 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -22,8 +22,4 @@ - - - - diff --git a/readme.md b/readme.md index dd987ea..2348aa8 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,8 @@ The `placetopay/app-version` package provides a way to know which version of your app is currently deployed. * It can be used with [Envoyer](https://envoyer.io/) deployment hooks -* It can be integrated with [Sentry](https://sentry.io) to help you keep track of Releases and Deploys in the Sentry Dashboard +* It can be integrated with [Sentry](https://sentry.io) to help you keep track of Releases and Deploys in the Sentry + Dashboard * Also you can integrate with [NewRelic](https://newrelic.com) to track each deployment in your APM ## Installation @@ -22,87 +23,92 @@ If you are using Sentry please follow this steps to configure the deployments an 1. Publish the configuration file - ```bash - php artisan vendor:publish --provider="PlacetoPay\AppVersion\VersionServiceProvider" - ``` + ```bash + php artisan vendor:publish --provider="PlacetoPay\AppVersion\VersionServiceProvider" + ``` 2. Set up your environment variables at `config/app-version.php` - ```php - return [ - 'sentry' => [ - /* - * The sentry auth token used to authenticate with Sentry Api - * Create tokens here at account level https://sentry.io/settings/account/api/auth-tokens/ - * Or here at organization level https://sentry.io/settings/your-organization/developer-settings/ - */ - 'auth_token' => env('APP_VERSION_SENTRY_AUTH'), - - /* - * The organization name this project belongs to, you can find out the - * organization at https://sentry.io/settings/ - */ - 'organization' => env('APP_VERSION_SENTRY_ORGANIZATION', 'placetopay'), - - /* - * The repository name of this project. Repositories are added in sentry as integrations. - * You must add your (Github|Bitbucket) integration at https://sentry.io/settings/your-organization/integrations/ - * and then add the repositories you want to track commits - */ - 'repository' => env('APP_VERSION_SENTRY_REPOSITORY'), - - /* - * The name of this project in Sentry Dashboard - * You can find out the project name at https://sentry.io/settings/your-organization/projects/ - */ - 'project' => env('APP_VERSION_SENTRY_PROJECT'), - ], - 'newrelic' => [ - /* - * The NewRelic Rest API Key, you can found it on the following URL when you are logged in - * https://rpm.newrelic.com/api/explore/application_deployments/create - */ - 'api_key' => env('APP_VERSION_NEWRELIC_API_KEY'), - - /* - * The NewRelic application id, you can get it from the URL in the APM - */ - 'application_id' => env('APP_VERSION_NEWRELIC_APPLICATION_ID'), - ], - +```php +return [ + 'sentry' => [ + /* + * The sentry auth token used to authenticate with Sentry Api + * Create tokens here at account level https://sentry.io/settings/account/api/auth-tokens/ + * Or here at organization level https://sentry.io/settings/your-organization/developer-settings/ + */ + 'auth_token' => env('APP_VERSION_SENTRY_AUTH'), + + /* + * The organization name this project belongs to, you can find out the + * organization at https://sentry.io/settings/ + */ + 'organization' => env('APP_VERSION_SENTRY_ORGANIZATION', 'placetopay'), + + /* + * The repository name of this project. Repositories are added in sentry as integrations. + * You must add your (Github|Bitbucket) integration at https://sentry.io/settings/your-organization/integrations/ + * and then add the repositories you want to track commits + */ + 'repository' => env('APP_VERSION_SENTRY_REPOSITORY'), + /* - * The current deployed version, will be read from version file - * generated by `php artisan app-version:create ...` command - */ - 'version' => \PlacetoPay\AppVersion\VersionFile::readSha(), - ]; - ``` + * The name of this project in Sentry Dashboard + * You can find out the project name at https://sentry.io/settings/your-organization/projects/ + */ + 'project' => env('APP_VERSION_SENTRY_PROJECT'), + ], + 'newrelic' => [ + /* + * The NewRelic Rest API Key, you can found it on the following URL when you are logged in + * https://rpm.newrelic.com/api/explore/application_deployments/create + */ + 'api_key' => env('APP_VERSION_NEWRELIC_API_KEY'), + + /* + * The NewRelic application id, you can get it from the URL in the APM + */ + 'application_id' => env('APP_VERSION_NEWRELIC_APPLICATION_ID'), + ], + + /* + * The current deployed version, will be read from version file + * generated by `php artisan app-version:create ...` command + */ + 'version' => \PlacetoPay\AppVersion\VersionFile::readSha(), + + /** + * the credentials to be able to see the deployed version. + */ + 'username' => env('APP_VERSION_USERNAME', 'admin'), + 'password' => env('APP_VERSION_PASSWORD', 'Testing123!'), +]; +``` 3. Set up the `config/sentry.php` file with the following settings - ```php - return [ +```php +return [ + 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), - 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), + // capture release as git sha + 'release' => \PlacetoPay\AppVersion\VersionFile::readSha(), - // capture release as git sha - 'release' => \PlacetoPay\AppVersion\VersionFile::readSha(), + 'breadcrumbs' => [ + // Capture Laravel logs in breadcrumbs + 'logs' => true, - 'breadcrumbs' => [ - // Capture Laravel logs in breadcrumbs - 'logs' => true, + // Capture SQL queries in breadcrumbs + 'sql_queries' => true, - // Capture SQL queries in breadcrumbs - 'sql_queries' => true, + // Capture bindings on SQL queries logged in breadcrumbs + 'sql_bindings' => true, - // Capture bindings on SQL queries logged in breadcrumbs - 'sql_bindings' => true, + // Capture queue job information in breadcrumbs + 'queue_info' => true, + ], - // Capture queue job information in breadcrumbs - 'queue_info' => true, - ], - - ]; - ``` +]; +``` ## Usage @@ -110,35 +116,40 @@ You can visit `https://yourapp.com/version` ### Envoyer Hooks -Using tools to deploy like [Envoyer](https://envoyer.io) there is no git source available once deployed so using the sha, project and branch available information we create a file containing this information +Using tools to deploy like [Envoyer](https://envoyer.io) there is no git source available once deployed so using the +sha, project and branch available information we create a file containing this information -1. Create a deployment hook in the action "Activate New Release", it is vital that this hook runs **BEFORE running config:cache or optimize commands** +1. Create a deployment hook in the action "Activate New Release", it is vital that this hook runs **BEFORE running + config:cache or optimize commands** - ```shell - cd {{ release }} - php artisan app-version:create --sha={{ sha }} --time={{ time }} --project={{ project }} --branch={{ branch }} - ``` +```shell +cd {{ release }} +php artisan app-version:create --sha={{ sha }} --time={{ time }} --project={{ project }} --branch={{ branch }} +``` - This will generate your version file at `storage/app/app-version.json` +This will generate your version file at `storage/app/app-version.json` -2. If you are integrating with Sentry or NewRelic Releases/Deployments/Issues, Add these hooks so Sentry and NewRelic can track your deployments. It should be run AFTER running the optimization or configuration cache. +2. If you are integrating with Sentry or NewRelic Releases/Deployments/Issues, Add these hooks so Sentry and NewRelic + can track your deployments. It should be run AFTER running the optimization or configuration cache. - ```shell - cd {{ release }} - php artisan app-version:create-release - php artisan app-version:create-deploy - ``` +```shell +cd {{ release }} +php artisan app-version:create-release +php artisan app-version:create-deploy +``` ### Know your version from CLI If you're using tinker you can get the version information with the following commands To access the version information generated with the step 1 of the usage + ```php config('app-version.version.sha'); ``` To access the sha + ```php PlacetoPay\AppVersion\VersionFile::readSha() ```