nucleos/relazy 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nucleos/relazy

Composer 安装命令:

composer require nucleos/relazy

包简介

relazy - The lazy release tool

README 文档

README

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Continuous Integration Code Coverage

Relazy is a handy tool to help releasing new versions of your software. You can define the type of version generator you want to use (e.g. semantic versioning), where you want to store the version (e.g. in a changelog file or as a VCS tag) and a list of actions that should be executed before or after the release of a new version.

This project was originally inspired by the RMT project, but with some major refactoring and more modern approach (e.g. PHP config with autocompletion).

Installation

Option 1: As a development dependency of your project

In order to use relazy in your project you should use Composer to install it as a dev-dependency. Just go to your project's root directory and execute:

composer require --dev nucleos/relazy

Then you must need to create a .relazy.php config file to run the relazy executable script in your project's root folder.

./relazy

Once there, your best option is to pick one of the configuration examples below and adapt it to your needs.

Option 2: As a global Composer installation

You can add relazy to your global composer.json and have it available globally for all your projects. Therefor just run the following command:

composer global require nucleos/relazy

Make sure you have ~/.composer/vendor/bin/ in your $PATH.

Option 3: As a Phar file

Relazy can be installed through phar-composer, which needs to be installed therefor. This useful tool allows you to create runnable Phar files from Composer packages.

If you have phar-composer installed, you can run:

phar-composer install nucleos/relazy

and have phar-composer build and install the Phar file to your $PATH, which then allows you to run it simply as relazy from the command line, or you can run

phar-composer build nucleos/relazy

and copy the resulting Phar file manually to where you need it. Either make the Phar file executable via chmod +x relazy.phar and execute it directly ./relazy.phar or run it by invoking it through PHP via php relazy.phar.

For the usage substitute relazy with whatever variant you have decided to use.

Usage

Using relazy is very straightforward, just run the command:

./relazy release

Relazy will then execute the following tasks:

  1. Execute the startup actions
  2. Ask the user to answer potentials questions
  3. Execute the pre-release actions
  4. Release
    • Generate a new version number
    • Persist the new version number
  5. Execute the post-release actions

Here is an example output:

Additional commands

The release command provides the main behavior of the tool, additional some extra commands are available:

  • current will show your project current version number (alias version)
  • changes display the changes that will be incorporated in the next release

Configuration

All relazy configurations have to be done in .relazy.php. The file is divided in the following elements:

  • vcs: The type of VCS you are using, can be Git or Noop
  • startupActions: A list [] of actions that will be executed just after startup without user interaction
  • preReleaseActions: A list [] of actions that will be executed before the release process
  • versionGenerator: The generator to use to create a new version (mandatory)
  • versionPersister: The persister to use to store the versions (mandatory)
  • postReleaseActions: A list [] of actions that will be executed after the release

All entries of this config work the same. You have to specify the class you want to handle the action. Example:

use Nucleos\Relazy\Changelog\Formatter\SemanticFormatter;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SimpleGenerator;
use Nucleos\Relazy\Version\Persister\TagPersister;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git()))
    ->versionGenerator(new SimpleGenerator())
    ->versionPersister(new TagPersister(tagPrefix: 'v_'))
    ->formatter(new SemanticFormatter())
    // ...
;

Extend it

Relazy is providing some existing actions, generators, and persisters. If needed you can add your own by creating a PHP script in your project, and referencing it in the configuration:

use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git()))
    ->versionGenerator(new \Acme\CustomGenerator())
    // ...
;

Configuration examples

Most of the time, it will be easier for you to pick up an example below and adapt it to your needs.

No VCS, changelog updater only

use Nucleos\Relazy\Changelog\Formatter\SemanticFormatter;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SimpleGenerator;
use Nucleos\Relazy\Version\Persister\ChangelogPersister;
use Nucleos\Relazy\VersionControl\Noop;

return (new RelazyConfig())
    ->versionGenerator(new SimpleGenerator())
    ->versionPersister(new ChangelogPersister())
    ->formatter(new SemanticFormatter())
    // ...
;

Using Git tags, simple versioning and startup actions

new Nucleos\Relazy\Action\VersionControl\CheckWorkingCopyAction;
new Nucleos\Relazy\Action\VersionControl\LastChangesAction;
use Nucleos\Relazy\Changelog\Formatter\SemanticFormatter;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SimpleGenerator;
use Nucleos\Relazy\Version\Persister\ChangelogPersister;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git()))
    ->versionGenerator(new SimpleGenerator())
    ->versionPersister(new ChangelogPersister())
    ->formatter(new SemanticFormatter())
    ->startupActions([
        new CheckWorkingCopyAction(),
        new DisplayLastChanges(),
    ])
;

Using Git tags, simple versioning and startup actions

use Nucleos\Relazy\Action\Composer\ValidateAction;
use Nucleos\Relazy\Action\Composer\StabilityCheckAction;
use Nucleos\Relazy\Action\Composer\DependencyStabilityCheckAction;
use Nucleos\Relazy\Changelog\Formatter\SemanticFormatter;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SimpleGenerator;
use Nucleos\Relazy\Version\Persister\TagPersister;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git(signCommit: true, signTag: true)))
    ->versionGenerator(new SimpleGenerator())
    ->versionPersister(new TagPersister())
    ->startupActions([
        new ValidateAction(),
        new StabilityCheckAction(),
        new DependencyStabilityCheckAction(allowList: [
            'symfony/console',
            'phpunit/phpunit' => 'require-dev',
        ]),
    ])
;

Using Git tags, simple versioning and startup actions, and gpg sign commit and tags

new Nucleos\Relazy\Action\VersionControl\CheckWorkingCopyAction;
new Nucleos\Relazy\Action\VersionControl\LastChangesAction;
use Nucleos\Relazy\Changelog\Formatter\SemanticFormatter;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SimpleGenerator;
use Nucleos\Relazy\Version\Persister\ChangelogPersister;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git(signCommit: true, signTag: true)))
    ->versionGenerator(new SimpleGenerator())
    ->versionPersister(new ChangelogPersister())
    ->startupActions([
        new CheckWorkingCopyAction(),
        new DisplayLastChanges(),
    ])
;

Using Git tags with prefix, semantic versioning, updating two files and pushing automatically

use Nucleos\Relazy\Action\Filesystem\FilesUpdateAction;
use Nucleos\Relazy\Action\VersionControl\PublishAction;
use Nucleos\Relazy\Config\RelazyConfig;
use Nucleos\Relazy\Version\Generator\SemanticGenerator;
use Nucleos\Relazy\Version\Persister\TagPersister;
use Nucleos\Relazy\VersionControl\Git;

return (new RelazyConfig(new Git(signCommit: true, signTag: true)))
    ->versionGenerator(new SemanticGenerator())
    ->versionPersister(new TagPersister(tagPrefix: 'v_'))
    ->preReleaseActions([
        new FilesUpdateAction(files: [
            'config.yml' => '%version%',
            'app.ini' => 'dynamic-version: %version%'
        ]),
    ])
    ->postReleaseActions([
        new PublishAction(),
    ])
;

nucleos/relazy 适用场景与选型建议

nucleos/relazy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 07 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「version」 「command」 「tag」 「release」 「semantic versioning」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nucleos/relazy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nucleos/relazy 我们能提供哪些服务?
定制开发 / 二次开发

基于 nucleos/relazy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-04