Upgrade a major version
Upgrade from 6.x to 7.x
Step 1: Update deploy.php
-
Change config
hostnametoalias. -
Change config
real_hostnametohostname. -
Change config
usertoremote_user. -
Update
host()definitions:- Add
setprefix to all setters:identityFile->setIdentityFileorset('identity_file') - Update
host(...)->addSshOption('UserKnownHostsFile', '/dev/null')tohost(...)->setSshArguments(['-o UserKnownHostsFile=/dev/null']); - Replace stage with labels, i.e.
When deploying instead of
host('deployer.org')
->set('labels', ['stage' => 'prod']);dep deploy produsedep deploy stage=prod. alias()is deleted,host()itself sets alias and hostname, to override hostname usesetHostname().
- Add
-
Update
task()definitions.- Replace
onRoles()withselect():task(...)
->select('stage=prod'); - Don't use string-based task definition, it's not available anymore. Don't forget to set correct working directory.
# from
task('deploy:npm-install', 'npm clean-install');
# to
task('deploy:npm-install', function() {
cd('{{release_path}}');
run('npm clean-install');
});
- Replace
-
Third party recipes now live inside main Deployer repo in contrib:
require 'contrib/rsync.php'; -
Replace
inventory()withimport(). It now can import hosts, configs, tasks:import: recipe/common.php
config:
application: deployer
shared_dirs:
- uploads
- storage/logs/
- storage/db
shared_files:
- .env
- config/test.yaml
keep_releases: 3
http_user: false
hosts:
prod:
local: true
tasks:
deploy:
- deploy:prepare
- deploy:vendors
- deploy:publish
deploy:vendors:
- run: "cd {{release_path}} && echo {{bin/composer}} {{composer_options}} 2>&1" -
Rename task
successtodeploy:successandcleanuptodeploy:cleanup. -
Verbosity functions (
isDebug(), etc) got deleted. Useoutput()->isDebug()instead. -
runLocally()commands are executed relative to the recipe file directory. This behaviour can be overridden via an environment variable:DEPLOYER_ROOT=. vendor/bin/dep taskname` -
Replace
local()tasks with combination ofonce()andrunLocally()func. -
Replace
locateBinaryPath()withwhich()func. -
Replace
default_stagewithdefault_selector, and adjust the value accordingly (for example: "prod" to "stage=prod"). -
Replace
onHosts()andonStage()with labels & selectors. -
Replace
setPrivate()withhidden(). -
Configuration property
writable_recursivedefaults tofalse. This behaviour can be overridden with:
set('writable_recursive', true);
.gitdirectory is not present in release directory anymore. The previous behavior can be restored with:
set('update_code_strategy', 'clone');
Step 2: Deploy
Since the release history numbering is not compatible between v6 and v7, you need to specify the release_name manually for the first time. Otherwise you start with release 1.
- Find out next release name (ssh to the host,
lsreleases dir, find the biggest number). Example:42. - Deploy with release_name:
dep deploy -o release_name=43
In case a rollback is needed, manually change the current symlink:
ln -nfs releases/42 current
In case there are multiple hosts with different release names, you should create a {{deploy_path}}/.dep/latest_release file in each host with the current release number of that particular host.
Upgrade from 5.x to 6.x
-
Changed branch option priority
If you have host definition with
branch(...)parameter, adding--branchoption will not override it any more. If nobranch(...)parameter persists, branch will be fetched from current local git branch.host('prod')
->set('branch', 'production')In order to return to old behavior add checking of
--branchoption.host('prod')
->set('branch', function () {
return input()->getOption('branch') ?: 'production';
}) -
Add
deploy:infotask to the beginning todeploytask. -
runreturns string instead ofDeployer\Type\ResultNow
runandrunLocallyreturnsstringinstead ofDeployer\Type\Result. Replace method calls as:run('command')->toString()→run('command')run('if command; then echo "true"; fi;')->toBool()→test('command')
-
env_varsrenamed toenvset('env_vars', 'FOO=bar');→set('env', ['FOO' => 'bar']);
If your are using Symfony recipe, then you need to change
envsetting:set('env', 'prod');→set('symfony_env', 'prod');
Upgrade from 4.x to 5.x
-
Servers to Hosts
server($hostname)tohost($hostname), andserver($name, $hostname)tohost($name)->hostname($hostname)localServer($name)tolocalhost()cluster($name, $nodes, $port)tohosts(...$hodes)serverList($file)toinventory($file)
If you need to deploy to same server use host aliases:
host('domain.com/green', 'domain.com/blue')
->set('deploy_path', '~/{{hostname}}')
...Or you can define different hosts with same hostname:
host('production')
->hostname('domain.com')
->set('deploy_path', '~/production')
...
host('beta')
->hostname('domain.com')
->set('deploy_path', '~/beta')
... -
Configuration options
- Rename
{{server.name}}to{{hostname}}
- Rename
-
DotArray syntax
In v5 access to nested arrays in config via dot notation was removed. If you was using it, consider to move to plain config options.
Refactor this:
set('a', ['b' => 1]);
// ...
get('a.b');To:
set('a_b', 1);
// ...
get('a_b'); -
Credentials
Best practice in new v5 is to omit credentials for connection in
deploy.phpand write them in~/.ssh/configinstead.identityFile($publicKeyFile,, $privateKeyFile, $passPhrase)toidentityFile($privateKeyFile)pemFile($pemFile)toidentityFile($pemFile)forwardAgent()toforwardAgent(true)
-
Tasks constraints
onlyOntoonHostsonlyOnStagetoonStage
Upgrade from 3.x to 4.x
-
Namespace for functions
Add to beginning of deploy.php next line:
use function Deployer\{server, task, run, set, get, add, before, after};If you are using PHP version less than 5.6, you can use this:
namespace Deployer; -
env()toset()/get()Rename all calls
env($name, $value)toset($name, $value).Rename all rvalue
env($name)toget($name).Rename all
server(...)->env(...)toserver(...)->set(...). -
Moved NonFatalException
Rename
Deployer\Task\NonFatalExceptiontoDeployer\Exception\NonFatalException. -
Prior release cleanup
Due to changes in release management, the new cleanup task will ignore any prior releases deployed with 3.x. These will need to be manually removed after migrating to and successfully releasing via 4.x.
Upgrade from 2.x to 3.x
-
->path('...')Replace your server paths configuration:
server(...)
->path(...);to:
server(...)
->env('deploy_path', '...');