ixnode/bash-version-manager

Bash 版本管理器

0.1.8 2023-08-14 20:09 UTC

This package is auto-updated.

Last update: 2024-09-14 22:21:20 UTC


README

此工具帮助您维护当前路径中的版本。它会递增补丁、次要或主要版本,并在相应的文件中替换它们。

创建新的 VERSION 文件

VERSION 文件用作版本号的源。如果缺失,可以自动创建。

❯ 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.

可选:创建 .env 文件

目前,可以在 .env 文件中替换变量 VERSION_APP

❯ cat <<EOT >> .env
# Version of this app
VERSION_APP=$(cat VERSION)

# Version of this app
VERSION_APP_LATEST=latest
EOT

显示当前版本

如果您想查看当前版本,请使用以下命令。

❯ 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)

切换补丁版本

要更改补丁版本,请使用标志 --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.

切换次要版本

要更改次要版本,请使用标志 --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.

切换主要版本

要更改主要版本,请使用标志 --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.

切换到指定版本

可以指定自定义版本(例如 1.2.3)作为参数来更改版本。

❯ 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.

使用其他工作目录

通常,该工具使用当前工作目录。这可以更改。

❯ 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)

显示帮助

显示工具的参数和参数。

❯ bin/version-manager --help

version-manager 0.1.0 (2022-01-16) - Björn Hempel <bjoern@hempel.li>

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.

显示 Git 提示

显示一些提交到 Git 仓库的有用命令。

❯ 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)"

与 PHP Composer 一起使用

composer require --dev ixnode/bash-version-manager
vendor/bin/version-manager --version
version-manager 0.1.2 (2022-12-18) - Björn Hempel <bjoern@hempel.li>

Version 类使用方法

use Ixnode\BashVersionManager\Version;
$versionArray = (new Version())->getAll();

执行测试

如果您想进行更改,测试模式可以帮助检查当前更改。测试模式使用测试文件夹中的文件

  • .env(源文件)
  • .env.major(与主要更改的比较文件)
  • .env.minor(与次要更改的比较文件)
  • .env.patch(与补丁更改的比较文件)
  • VERSION(源文件)
  • VERSION.major(与主要更改的比较文件)
  • VERSION.minor(与次要更改的比较文件)
  • VERSION.patch(与补丁更改的比较文件)
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.

许可协议

此工具遵循 MIT 许可协议 - 请参阅 LICENSE.md 文件以获取详细信息