mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 08:45:04 +01:00
Add release automation
This commit is contained in:
parent
bd3f582336
commit
147eca79a9
60
bin/release
Executable file
60
bin/release
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
$binDepPath = __DIR__ . '/dep';
|
||||
$content = file_get_contents($binDepPath);
|
||||
preg_match("/define\('DEPLOYER_VERSION', '(?<version>.+?)'\);/", $content, $matches);
|
||||
$version = $newVersion = $matches['version'];
|
||||
echo "Current version is $version\n";
|
||||
|
||||
$opt = getopt(null, ['patch']);
|
||||
|
||||
if (array_key_exists('patch', $opt)) {
|
||||
if (preg_match('/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-master$/', $version, $matches)) {
|
||||
['major' => $major, 'minor' => $minor, 'patch' => $patch] = $matches;
|
||||
$patch++;
|
||||
$newVersion = "$major.$minor.$patch";
|
||||
} else {
|
||||
echo "Patch can be only applied for master version.\n";
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$newVersion = $argv[1] ?? '';
|
||||
if (empty($newVersion)) {
|
||||
echo "Specify a version 1.2.3 or --patch.\n";
|
||||
exit(1);
|
||||
}
|
||||
if (!preg_match('/^\d+\.\d+\.\d+(\-\w+(\.\d+)?)?$/', $newVersion)) {
|
||||
echo "Version must follow semver. Got $newVersion\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($version === $newVersion) {
|
||||
echo "New version $newVersion is same as old version $version.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$content = str_replace($version, $newVersion, $content);
|
||||
file_put_contents($binDepPath, $content);
|
||||
|
||||
`git add $binDepPath`;
|
||||
`git commit -m 'Release $newVersion'`;
|
||||
`git tag v$newVersion`;
|
||||
echo "Release $newVersion\n";
|
||||
|
||||
preg_match('/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/', $newVersion, $matches);
|
||||
['major' => $major, 'minor' => $minor, 'patch' => $patch] = $matches;
|
||||
$masterVersion = "$major.$minor.$patch-master";
|
||||
|
||||
$content = str_replace($newVersion, $masterVersion, $content);
|
||||
file_put_contents($binDepPath, $content);
|
||||
|
||||
`git add $binDepPath`;
|
||||
`git commit -m 'Back to master'`;
|
||||
echo "Commit $masterVersion\n";
|
40
deploy.yaml
Normal file
40
deploy.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
hosts:
|
||||
deployer.org: ~
|
||||
|
||||
tasks:
|
||||
pull:
|
||||
script:
|
||||
- cd ~/dev/deployer
|
||||
- git pull
|
||||
- git status
|
||||
|
||||
test:
|
||||
script:
|
||||
- cd ~/dev/deployer
|
||||
- composer install
|
||||
- composer test
|
||||
- bin/build
|
||||
- php deployer.phar -v
|
||||
|
||||
release:composer:
|
||||
script:
|
||||
- cd ~/dev/deployer
|
||||
- bin/release
|
||||
|
||||
release:phar:
|
||||
script:
|
||||
- .
|
||||
|
||||
release:dist:
|
||||
script:
|
||||
- .
|
||||
|
||||
release:
|
||||
- release:composer
|
||||
- release:phar
|
||||
- release:dist
|
||||
|
||||
before:
|
||||
release:
|
||||
- pull
|
||||
- test
|
Loading…
x
Reference in New Issue
Block a user