|
1 | 1 | # Laravel Application Self-Updater
|
2 | 2 |
|
3 |
| -[](https://packagist.org/packages/codedge/laravel-selfupdater) |
4 |
| -[](https://packagist.org/packages/codedge/laravel-selfupdater) |
5 |
| -[](https://github.com/codedge/laravel-selfupdater/actions) |
6 |
| -[](https://styleci.io/repos/64463948) |
7 |
| -[](https://www.codacy.com/app/codedge/laravel-selfupdater?utm_source=github.com&utm_medium=referral&utm_content=codedge/laravel-selfupdater) |
8 |
| -[](https://codecov.io/gh/codedge/laravel-selfupdater) |
| 3 | +I am moving off Github to Codeberg. |
9 | 4 |
|
10 |
| -This package provides some basic methods to implement a self updating |
11 |
| -functionality for your Laravel application. |
12 |
| - |
13 |
| -**Supported update provider:** |
14 |
| - |
15 |
| -- GitHub |
16 |
| -- Gitlab |
17 |
| -- Gitea |
18 |
| -- Http-based archives |
19 |
| - |
20 |
| -Usually you need this when distributing a self-hosted Laravel application |
21 |
| -that needs some updating mechanism without [Composer](https://getcomposer.org/). |
22 |
| - |
23 |
| -## Install |
24 |
| - |
25 |
| -To install the latest version from the master using [Composer](https://getcomposer.org/): |
26 |
| - |
27 |
| -```sh |
28 |
| -$ composer require codedge/laravel-selfupdater |
29 |
| -``` |
30 |
| - |
31 |
| -## Configuration |
32 |
| - |
33 |
| -After installing the package you need to publish the configuration file via |
34 |
| - |
35 |
| -```sh |
36 |
| -$ php artisan vendor:publish --provider="Codedge\Updater\UpdaterServiceProvider" |
37 |
| -``` |
38 |
| - |
39 |
| -**Note:** Please enter correct value for vendor and repository name in your `config/self-updater.php` if you want to use Github as source for your updates. |
40 |
| - |
41 |
| -### Setting the currently installed version |
42 |
| - |
43 |
| -Before starting an update, make sure to set the version installed correctly. |
44 |
| -You're responsible to set the current version installed, either in the config file or better via the env variable `SELF_UPDATER_VERSION_INSTALLED`. |
45 |
| - |
46 |
| -#### `tag`-based updates |
47 |
| - |
48 |
| -Set the installed version to one of the tags set for a release. |
49 |
| - |
50 |
| -#### `branch`-based updates |
51 |
| - |
52 |
| -Set the installed version to a datetime of one of the latest commits. |
53 |
| -A valid version would be: `2020-04-19T22:35:48Z` |
54 |
| - |
55 |
| -### Running artisan commands |
56 |
| - |
57 |
| -Artisan commands can be run before or after the update process and can be configured in `config/self-updater.php`: |
58 |
| - |
59 |
| -**Example:** |
60 |
| - |
61 |
| -```php |
62 |
| -'artisan_commands' => [ |
63 |
| - 'pre_update' => [ |
64 |
| - 'updater:prepare' => [ |
65 |
| - 'class' => \App\Console\Commands\PreUpdateTasks::class, |
66 |
| - 'params' => [] |
67 |
| - ], |
68 |
| - ], |
69 |
| - 'post_update' => [ |
70 |
| - 'postupdate:cleanup' => [ |
71 |
| - 'class' => \App\Console\Commands\PostUpdateCleanup::class, |
72 |
| - 'params' => [ |
73 |
| - 'log' => 1, |
74 |
| - 'reset' => false, |
75 |
| - // etc. |
76 |
| - ] |
77 |
| - ] |
78 |
| - ] |
79 |
| -] |
80 |
| -``` |
81 |
| - |
82 |
| -### Configure the download path |
83 |
| - |
84 |
| -Sometimes your web host does not allow saving files into the `/tmp` folder of the server. You can change the folder the application is downloaded to by setting the |
85 |
| -env var `SELF_UPDATER_DOWNLOAD_PATH` to something different. Just keep in mind, that the folder is not inside the folder your application lives in as it might be overwritten |
86 |
| -during the update. |
87 |
| - |
88 |
| -### Notifications via email |
89 |
| - |
90 |
| -You need to specify a recipient email address and a recipient name to receive |
91 |
| -update available notifications. |
92 |
| -You can specify these values by adding `SELF_UPDATER_MAILTO_NAME` and |
93 |
| -`SELF_UPDATER_MAILTO_ADDRESS` to your `.env` file. |
94 |
| - |
95 |
| -| Config name | Description | |
96 |
| -| -------------------------------------------- | --------------------------------- | |
97 |
| -| SELF_UPDATER_MAILTO_NAME | Name of email recipient | |
98 |
| -| SELF_UPDATER_MAILTO_ADDRESS | Address of email recipient | |
99 |
| -| SELF_UPDATER_MAILTO_UPDATE_AVAILABLE_SUBJECT | Subject of update available email | |
100 |
| -| SELF_UPDATER_MAILTO_UPDATE_SUCCEEDED_SUBJECT | Subject of update succeeded email | |
101 |
| - |
102 |
| -### Private repositories |
103 |
| - |
104 |
| -Private repositories can be accessed via (Bearer) tokens. Each repository inside the config file should have |
105 |
| -a `private_access_token` field, where you can set the token. |
106 |
| - |
107 |
| -ℹ Do not prefix the token with `Bearer `. This is done automatically. |
108 |
| - |
109 |
| -## Usage |
110 |
| - |
111 |
| -To start an update process, i. e. in a controller, just use: |
112 |
| - |
113 |
| -```php |
114 |
| -Route::get('/', function (\Codedge\Updater\UpdaterManager $updater) { |
115 |
| - |
116 |
| - // Check if new version is available |
117 |
| - if($updater->source()->isNewVersionAvailable()) { |
118 |
| - |
119 |
| - // Get the current installed version |
120 |
| - echo $updater->source()->getVersionInstalled(); |
121 |
| - |
122 |
| - // Get the new version available |
123 |
| - $versionAvailable = $updater->source()->getVersionAvailable(); |
124 |
| - |
125 |
| - // Create a release |
126 |
| - $release = $updater->source()->fetch($versionAvailable); |
127 |
| - |
128 |
| - // Run the update process |
129 |
| - $updater->source()->update($release); |
130 |
| - |
131 |
| - } else { |
132 |
| - echo "No new version available."; |
133 |
| - } |
134 |
| - |
135 |
| -}); |
136 |
| -``` |
137 |
| - |
138 |
| -Currently, the fetching of the source is a _synchronous_ process. It is not run in background. |
139 |
| - |
140 |
| -### Using GitHub |
141 |
| - |
142 |
| -The package comes with a _GitHub_ source repository type to fetch |
143 |
| -releases from GitHub - basically use GitHub to pull the latest version |
144 |
| -of your software. |
145 |
| - |
146 |
| -Just make sure you set the proper repository in your `config/self-updater.php` |
147 |
| -file. |
148 |
| - |
149 |
| -#### Tag-based updates |
150 |
| - |
151 |
| -This is the default. Updates will be fetched by using a tagged commit, aka release. |
152 |
| - |
153 |
| -#### Branch-based updates |
154 |
| - |
155 |
| -Select the branch that should be used via the `use_branch` setting [inside the configuration](https://github.com/codedge/laravel-selfupdater/blob/master/config/self-update.php). |
156 |
| - |
157 |
| -```php |
158 |
| -// ... |
159 |
| -'repository_types' => [ |
160 |
| - 'github' => [ |
161 |
| - 'type' => 'github', |
162 |
| - 'repository_vendor' => env('SELF_UPDATER_REPO_VENDOR', ''), |
163 |
| - 'repository_name' => env('SELF_UPDATER_REPO_NAME', ''), |
164 |
| - // ... |
165 |
| - 'use_branch' => 'v2', |
166 |
| - ], |
167 |
| - // ... |
168 |
| -]; |
169 |
| -``` |
170 |
| - |
171 |
| -### Using Gitlab |
172 |
| - |
173 |
| -Configure Gitlab either via the `config/self-updater.php` or use the appropriate environment variables. |
174 |
| - |
175 |
| -```php |
176 |
| -// ... |
177 |
| -'repository_types' => [ |
178 |
| - 'gitlab' => [ |
179 |
| - 'base_url' => '', |
180 |
| - 'type' => 'gitlab', |
181 |
| - 'repository_id' => env('SELF_UPDATER_REPO_URL', ''), |
182 |
| - 'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'), |
183 |
| - 'private_access_token' => env('SELF_UPDATER_GITLAB_PRIVATE_ACCESS_TOKEN', ''), |
184 |
| - ], |
185 |
| - // ... |
186 |
| -]; |
187 |
| -``` |
188 |
| - |
189 |
| -ℹ Although the environment variable is named `SELF_UPDATER_REPO_URL`, only specify your repository id. |
190 |
| - |
191 |
| -For self-hosted Gitlab instances you can set the `base_url` variable to a domain where the instance is hosted at, f. ex. `http://gitlab.acme.local`. |
192 |
| - |
193 |
| -### Using HTTP archives |
194 |
| - |
195 |
| -The package comes with an _HTTP_ source repository type to fetch |
196 |
| -releases from an HTTP directory listing containing zip archives. |
197 |
| - |
198 |
| -To run with HTTP archives, use following settings in your `.env` file: |
199 |
| - |
200 |
| -| Config name | Value / Description | |
201 |
| -| -------------------------------- | ------------------------------------------ | |
202 |
| -| SELF_UPDATER_SOURCE | `http` | |
203 |
| -| SELF_UPDATER_REPO_URL | Archive URL, e.g. `http://archive.webapp/` | |
204 |
| -| SELF_UPDATER_PKG_FILENAME_FORMAT | Zip package filename format | |
205 |
| -| SELF_UPDATER_DOWNLOAD_PATH | Download path on the webapp host server | |
206 |
| - |
207 |
| -The archive URL should contain nothing more than a simple directory listing with corresponding zip-Archives. |
208 |
| - |
209 |
| -`SELF_UPDATER_PKG_FILENAME_FORMAT` contains the filename format for all webapp update packages. I.e. when the update packages listed on the archive URL contain names like `webapp-v1.2.0.zip`, `webapp-v1.3.5.zip`, ... then the format should be `webapp-v_VERSION_`. The `_VERSION_` part is used as semantic versionioning variable for `MAJOR.MINOR.PATCH` versioning. The zip-extension is automatically added. |
210 |
| - |
211 |
| -The target archive files must be zip archives and should contain all files on root level, not within an additional folder named like the archive itself. |
212 |
| - |
213 |
| -### Using Gitea |
214 |
| - |
215 |
| -With _Gitea_ you can use your own Gitea-Instance with tag-releases. |
216 |
| - |
217 |
| -To use it, use the following settings in your `.env` file: |
218 |
| - |
219 |
| -| Config name | Value / Description | |
220 |
| -| --------------------------------------- | --------------------------------------- | |
221 |
| -| SELF_UPDATER_SOURCE | `gitea` | |
222 |
| -| SELF_UPDATER_GITEA_URL | URL of Gitea Server | |
223 |
| -| SELF_UPDATER_REPO_VENDOR | Repo Vendor Name | |
224 |
| -| SELF_UPDATER_REPO_NAME | Repo Name | |
225 |
| -| SELF_UPDATER_GITEA_PRIVATE_ACCESS_TOKEN | Access Token from Gitea | |
226 |
| -| SELF_UPDATER_DOWNLOAD_PATH | Download path on the webapp host server | |
227 |
| - |
228 |
| -## Contributing |
229 |
| - |
230 |
| -Please see the [contributing guide](CONTRIBUTING.md). |
231 |
| - |
232 |
| -## Licence |
233 |
| - |
234 |
| -The MIT License (MIT). Please see [Licence file](LICENSE) for more information. |
| 5 | +This package has been migrated to https://codeberg.org/codedge/laravel-selfupdater. |
| 6 | +If you encounter any issues, please open an issue at the new location. |
0 commit comments