marcohoutmandev / rmt-versioning
Extension for the RMT package. Used for adding custom versioning + changelog handeling.
Requires
- php: ~8.4.0 || ~8.5.0
- liip/rmt: ^1.9
Requires (Dev)
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.1
- squizlabs/php_codesniffer: ^4.0
README
This is an extension package for the liip/RMT tool, which helps developers with the release of new version of their software. Out-of-the box the RMT tool creates tags and even a changelog, but the generation of the changelog is always a single line. With bigger projects, chances are you want to release more than one committed changes and bundle them before creating a new release.
This is where this extension helps. There are three actions you can use when creating a new release. You can use all three, or just one.
VersionTxtAction.
The version number generated by RMT is used as a tag number. The VersionTxtAction writes this generated version number in a file called 'VERSION.txt' and saves it in the root (= default location) or an other specified folder within the project.
ChangelogTxtAction
Instead of asking for a single line of text to add to a changlog, this action depends on a file (CHANGELOG.txt) which the developer maintains. For every commit (or feature/hotfix branch merged) the developer may add one or more lines at the top of the file, creating a changelog summary. When this action gets called, it writes the version number with the date and time of the release at the top of the file.
ComposerJsonAction
Whether it is done as a best practice or needed by GitHub/Packagist/etc adding the version number to the composer.json when creating a new release is done automatically when you use this action.
Usage
Install the liip/RMT tool. See https://github.com/liip/RMT
Then install this extension by running:
composer require --dev marcohoutmandev/rmt-versioning
With the installation of the RMT tool, there is also a configuration file in the root of the project called '.rmt.yml'. Edit this file. Find the 'pre-release-action' part (there is usually two of them, one for the master branch and one default). Replace the existing standard actions with the ones you want to use from this extension. You are free to use any or all of them and even combine them with other (standard) RMT pre-release-actions. The file may look like this:
# BRANCH SPECIFIC CONFIG
# On master, we override the general config
master:
version-generator: semantic # More complex versionning (semantic)
version-persister:
vcs-tag:
tag-prefix: '' # No more prefix for tags
pre-release-actions:
vendor/marcohoutmandev/rmt-versioning/bin/UpdateVersionTxtAction.php: ~
vendor/marcohoutmandev/rmt-versioning/bin/UpdateChangelogTxtAction.php: ~
vendor/marcohoutmandev/rmt-versioning/bin/UpdateComposerJsonAction.php: ~
vcs-commit: ~ # Commit the CHANGELOG
Then run the RMT command just like you are used to, but sit back and relax while the actions do all the manual work for you.