This tool helps you to maintain the versions in the current path. It increments the patch, minor or major version and replaces them in the corresponding files.
The VERSION
file is used as the source for the version number. A missing file can be created
automatically.
❯ bin/version-manager --current
[2022-01-16 16:51:41] (error) → Version file "~/ixno/bash-version-manager/VERSION" not found.
Do you want to create a version file "VERSION" with version "0.1.0"? y
[2022-01-16 16:51:43] (error) → Version file "~/ixno/bash-version-manager/VERSION" successfully created.
Currently, the variable VERSION_APP
can be replaced in the .env
file:
❯ cat <<EOT >> .env
# Version of this app
VERSION_APP=$(cat VERSION)
# Version of this app
VERSION_APP_LATEST=latest
EOT
If you want to see the current version, use the following command.
❯ bin/version-manager --current
Current version: 0.1.0
Next major version: 1.0.0 (Use bin/version-manager --major)
Next minor version: 0.2.0 (Use bin/version-manager --minor)
Next patch version: 0.1.1 (Use bin/version-manager --patch)
To change the patch version use the flag --patch
.
❯ bin/version-manager --patch
Current version: 0.1.0
New version: 0.1.1
Do you want to set the new version "0.1.1" (y/n)? y
[2022-01-16 16:57:46] (info) → Set version "0.1.1" to "~/ixno/bash-version-manager/VERSION"
[2022-01-16 16:57:46] (success) → Done.
[2022-01-16 16:57:46] (info) → Set version "0.1.1" to "~/ixno/bash-version-manager/.env"
[2022-01-16 16:57:46] (success) → Done.
To change the minor version use the flag --minor
.
❯ bin/version-manager --minor
Current version: 0.1.0
New version: 0.2.0
Do you want to set the new version "0.2.0" (y/n)? y
[2022-01-16 16:58:32] (info) → Set version "0.2.0" to "~/ixno/bash-version-manager/VERSION"
[2022-01-16 16:58:32] (success) → Done.
[2022-01-16 16:58:32] (info) → Set version "0.2.0" to "~/ixno/bash-version-manager/.env"
[2022-01-16 16:58:32] (success) → Done.
To change the major version use the flag --major
.
❯ bin/version-manager --major
Current version: 0.1.0
New version: 1.0.0
Do you want to set the new version "1.0.0" (y/n)? y
[2022-01-16 16:59:06] (info) → Set version "1.0.0" to "~/ixno/bash-version-manager/VERSION"
[2022-01-16 16:59:06] (success) → Done.
[2022-01-16 16:59:06] (info) → Set version "1.0.0" to "~/ixno/bash-version-manager/.env"
[2022-01-16 16:59:06] (success) → Done.
A custom version (e.g. 1.2.3
) for changing versions can be specified as a parameter.
❯ bin/version-manager 1.2.3
Current version: 0.1.0
New version: 1.2.3
Do you want to set the new version "1.2.3" (y/n)? y
[2022-01-16 18:11:41] (info) → Set version "1.2.3" to "/home/bjoern/Development/ixno/bash-version-manager/VERSION"
[2022-01-16 18:11:41] (success) → Done.
[2022-01-16 18:11:41] (info) → Set version "1.2.3" to "/home/bjoern/Development/ixno/bash-version-manager/.env"
[2022-01-16 18:11:41] (success) → Done.
Usually the tool uses the current working directory. This can be changed.
❯ bin/version-manager --working-dir test --current
Current version: 0.2.1
Next major version: 1.0.0 (Use bin/version-manager --major)
Next minor version: 0.3.0 (Use bin/version-manager --minor)
Next patch version: 0.2.2 (Use bin/version-manager --patch)
Shows the parameters and arguments of the tool.
❯ bin/version-manager --help
version-manager 0.1.0 (2022-01-16) - Björn Hempel <[email protected]>
Usage: version-manager [...options] [version]
-c, --current Shows the current version.
-X, --major Will increase the major version (x.0.0).
-m, --minor Will increase the minor version (0.x.0).
-p, --patch Will increase the patch version (0.0.x).
-w, --working-dir Sets the current working-dir (default: "~/ixno/bash-version-manager")
-s, --show-hints Shows some hints.
-h, --help Shows this help.
-V, --version Shows the version number.
Shows some useful commands for committing to the Git repository.
❯ bin/version-manager --show-hints
Now you can do the following:
→ Edit your CHANGELOG.md file
❯ vi CHANGELOG.md
→ Usually version changes are set in the main or master branch
❯ git checkout main && git pull
→ Commit your changes to your repo
❯ git add CHANGELOG.md && git commit -m "Add version $(cat VERSION)" && git push
→ Tag your version
❯ git tag -a "$(cat VERSION)" -m "Version $(cat VERSION)" && git push origin "$(cat VERSION)"
composer require --dev ixnode/bash-version-manager
vendor/bin/version-manager --version
version-manager 0.1.2 (2022-12-18) - Björn Hempel <[email protected]>
use Ixnode\BashVersionManager\Version;
$versionArray = (new Version())->getAll();
If you want to make changes, the test mode helps to check the current changes. Test mode uses the files in the test folder:
.env
(source file).env.major
(comparison file with major change).env.minor
(comparison file with minor change).env.patch
(comparison file with patch change)VERSION
(source file)VERSION.major
(comparison file with major change)VERSION.minor
(comparison file with minor change)VERSION.patch
(comparison file with patch change)
bin/version-manager --test
[2022-01-16 16:50:57] (info) → The sha1 keys match (major).
[2022-01-16 16:50:57] (info) → The sha1 keys match (major).
[2022-01-16 16:50:57] (info) → The sha1 keys match (minor).
[2022-01-16 16:50:57] (info) → The sha1 keys match (minor).
[2022-01-16 16:50:57] (info) → The sha1 keys match (patch).
[2022-01-16 16:50:57] (info) → The sha1 keys match (patch).
[2022-01-16 16:50:57] (success) → All tests were completed successfully.
This tool is licensed under the MIT License - see the LICENSE.md file for details