deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.41k stars 1.47k forks source link

Keep releases do not work properly #3737

Open antonmedv opened 7 months ago

antonmedv commented 7 months ago

This workaround solved the problem for us. Add to your deploy.php file:

desc('Fix release_log file');
task('fix:release_log', function() {
    cd('{{deploy_path}}');

    if(test('[ -f .dep/releases_log ]')) {
        $releasesLog = implode("\n", array_map(function($line) {
            if(json_decode($line) === null) {
                $line = str_replace('{ ', '{ "', str_replace(' }', '" }', $line));
                $line = str_replace(' : ', '": "', str_replace(' , ', '", "', $line));
            }

            return $line;
        }, explode("\n", run('cat .dep/releases_log'))));

        run("echo '" . str_replace("'", "'\\''", $releasesLog) . "' > .dep/releases_log");
    }
});

Then, add before('deploy:cleanup', 'fix:release_log'); to fix the log before the cleanup task.

Originally posted by @david-windsock in https://github.com/deployphp/deployer/discussions/3511#discussioncomment-7690796

Upvote & Fund

Fund with Polar

david-windsock commented 7 months ago

Thanks @antonmedv, I was going to a new issue but let's keep all here. The problem seems to occur only when a deploy is made from Windows to Linux, resulting in an invalid _releaselog file format. Each line are not properly escaped (resulting in JSON without double quotes) so _releaseslog skips all invalid releases.

I think the bug was introduced on 7.1.0 release, because prior to january 2023 the _releaselog seems to be OK.

Pull requests #3569 and #3603 must solve this problem...

david-windsock commented 4 months ago

Just to keep this updated: #3569 was discarded in favor of #3603, which was merged two weeks ago. Now waiting for a new release...

david-windsock commented 2 months ago

There is an estimated date for the next release? Thanks!

antonmedv commented 2 months ago

Will try to release today.

david-windsock commented 2 months ago

Thanks @antonmedv