diff --git a/README.md b/README.md index e2653b8..57f9ace 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,19 @@ to bump the version changelog: add chapter with latest changes to CHANGELOG.md ``` +## Example: + + > setver new patch + ✔ version 1.12.0 -> 1.12.1 + ✔ set version in package.json + ✔ set version in composer.json + ✔ set version in .env.example + ✔ set version in VERSION.md + ✔ commit and push changed files + ✔ push tags to git@github.com:pforret/setver.git + ✔ to create a release, go to https://github.com/pforret/setver + + ## Installation with [basher](https://github.com/basherpm/basher) @@ -60,18 +73,6 @@ or the hard way # if you want the script to be in your path ln -s /setver /usr/local/bin/ -## Example: - - > setver new patch - ✔ version 1.12.0 -> 1.12.1 - ✔ set version in package.json - ✔ set version in composer.json - ✔ set version in .env.example - ✔ set version in VERSION.md - ✔ commit and push changed files - ✔ push tags to git@github.com:pforret/setver.git - ✔ to create a release, go to https://github.com/pforret/setver - ## References * https://semver.org/ diff --git a/composer.json b/composer.json index 1345c55..638171f 100644 --- a/composer.json +++ b/composer.json @@ -10,4 +10,5 @@ ], "require": {}, "version": "1.15.0" + "version": "1.14.4" } diff --git a/setver.sh b/setver.sh index cd47e87..5bb1daf 100755 --- a/setver.sh +++ b/setver.sh @@ -35,11 +35,13 @@ env_example=".env.example" verbose=0 check_in_root=1 usage=0 -while getopts rvh option ; do +prefix="v" +while getopts rvhp: option ; do case $option in r) check_in_root=0 ;; v) verbose=1 ;; h) usage=1 ;; + p) prefix="$OPTARG" ;; *) echo "Unknown option -$option" esac done @@ -111,7 +113,7 @@ main() { changes | changelog) #USAGE: setver changelog: format new CHANGELOG.md chapter - add_to_changedebug "$(get_any_version)" + add_to_changelog "$(get_any_version)" ;; history) @@ -152,6 +154,7 @@ show_usage_and_quit() { $script_fname [-h] [-v] [-s] [get/check/push/auto/skip/set/new/history/changelog] [version] -h: extended help -v: verbose mode (more output to stderr) + -p : use as prefix for git tag (default: "v") -s: add [skip_ci] flag to get : get current version (from git tag and composer) -- can be used in scripts check : compare versions of git tag and composer @@ -205,6 +208,7 @@ get_version_tag() { if [[ -n $(git tag) ]] ; then git tag \ | sed 's/v//' \ + | sed "s/$prefix//" \ | awk -F. '{printf("%04d.%04d.%04d\n",$1,$2,$3);}' \ | sort \ | tail -1 \ @@ -411,7 +415,7 @@ set_versions() { if [[ $uses_npm -gt 0 ]]; then # for NPM/node repos # first change package.json - success "set version in package.json" + success "set version in package.json: $new_version" wait 1 npm version "$new_version" skip_git_tag=1 # npm also creates the tag @@ -423,7 +427,7 @@ set_versions() { if [[ $uses_composer -gt 0 ]]; then # for PHP repos # first change composer.json - success "set version in composer.json" + success "set version in composer.json: $new_version" wait 1 composer config version "$new_version" 2> /dev/null @@ -434,7 +438,7 @@ set_versions() { ### .env if [[ $uses_env -gt 0 ]]; then # for Ruby/PHP/bash/... - success "set version in $env_example" + success "set version in $env_example: $new_version" wait 1 env_temp="$env_example.tmp" awk -F= -v version="$new_version" ' @@ -460,7 +464,7 @@ set_versions() { ### VERSION.md if [[ -f VERSION.md ]]; then # for bash repos - success "set version in VERSION.md" + success "set version in VERSION.md: $new_version" wait 1 echo "$new_version" >VERSION.md git add VERSION.md @@ -475,9 +479,9 @@ set_versions() { # now create new version tag if [[ $skip_git_tag == 0 ]]; then - success "set git version tag" + success "set git version tag: $prefix$new_version" wait 1 - git tag "v$new_version" + git tag "$prefix$new_version" fi # also push tags to github/bitbucket