Detect old .dep/releases file to find out next release (and delete old file)
Just a suggestion for a smoother upgrade path - why not detect the presence of an already existing .dep/releases file to determine the last release number from v6.x and then clean up afterwards by deleting it?
I'm assuming the .dep/releases file is safe to remove after upgrading to v7?
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
It's possible to write such migration code, but instead, I wrote migration documentation. Why? Because it's easier. =)
I work on Deployer only on my spare time, and only because of my supporters on https://github.com/sponsors/antonmedv, so...
I have a big backlog of other important stuff to do too, like finally releasing v7. If you would like to write such code yourself? +tests of cause, it pretty complex actually. Might be lots of hidden underwater rocks.
Completely understand, it was just a feature suggestion. I love Deployer by the way.
I have created simple task for this, without tests, so use it with caution.
<?php declare(strict_types = 1);
namespace Deployer;
task('deploy:custom:deployer-migration', function (): void {
$v6FileExists = test('[ -f {{deploy_path}}/.dep/releases ]');
$v7FileExists = test('[ -f {{deploy_path}}/.dep/latest_release ]');
if ($v6FileExists && !$v7FileExists) {
$releasesLastRow = run('tail -n 1 {{deploy_path}}/.dep/releases');
[, $lastReleaseNumber] = explode(',', $releasesLastRow);
run(sprintf('echo %s > {{deploy_path}}/.dep/latest_release', $lastReleaseNumber));
run(sprintf('rm -f {{deploy_path}}/.dep/releases'));
writeln(sprintf('Migrated deployer v6.x releases file to v7.x latest_release file.'));
}
});
And need to create .dep/releases_log with at least one row to have correctly set up previous_release in recipe/deploy/release.php
I created a small PHP script to convert the release files: https://gist.github.com/retiolum/1fa9a7511bc5095b33dc8c09224306a9