vaslv / composer-release
Interactive release helper: picks the next semver version from existing git tags, tags and pushes; bumps composer.json's version field only when the project already commits one. Available as `composer release`.
Package info
github.com/vaslv/composer-release
Language:Shell
Type:composer-plugin
pkg:composer/vaslv/composer-release
Requires
- php: >=7.4
- composer-plugin-api: ^2.0
Requires (Dev)
- composer/composer: ^2.0
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^9.6
README
Interactive release helper for Composer projects. It looks at your existing git
tags, offers the next patch / minor / major version, writes it to
composer.json, then commits, tags and (optionally) pushes — so you never have
to check what the last version was before cutting a release.
Current version: v1.4.2
Select next version:
1) patch → v1.4.3
2) minor → v1.5.0
3) major → v2.0.0
4) custom
q) quit
Requirements
- bash, git and composer available in
PATH - Composer 2.x
Installation
composer require --dev vaslv/composer-release
The package is a Composer plugin, so on first install Composer will ask whether
you trust it. Answer y, or allow it up front:
composer config allow-plugins.vaslv/composer-release true
Usage
The plugin registers a native Composer command:
composer release
The script is also exposed through vendor/bin, so these work too:
vendor/bin/release
composer exec release
What it does
- Refuses to run with a dirty working tree or on a detached HEAD; warns when
you are not on
main/master. - Fetches tags from
origin(when the remote exists), then finds the latest semver tag —1.2.3andv1.2.3styles are both supported, mixed styles compare correctly, and the existing prefix is preserved. - Lets you pick patch / minor / major / custom for the next version.
- If
composer.jsonalready commits aversionfield, updates it and commits aschore(release): <tag>(restoring the file if the commit fails). Without the field — the Packagist-recommended setup — the release is tag-only. - Creates an annotated tag.
- Asks whether to push the branch and the tag to
originin one atomic push.
Every destructive step asks for confirmation first; nothing is pushed without an explicit yes.
Development
composer install composer analyse # PHPStan, level max composer test # PHPUnit smoke tests for the plugin wiring bats tests/release.bats # end-to-end tests for the release script
License
MIT