Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jv-k/ver-bump
📦 A really fast & lightweight CLI utility that takes care of releasing Git software projects, put together purely with bash scripting.
https://github.com/jv-k/ver-bump
automation bump-version bumpversion changelog git git-branch-develop package publish release release-automation semver ver-bump version version-bump versioning
Last synced: 4 days ago
JSON representation
📦 A really fast & lightweight CLI utility that takes care of releasing Git software projects, put together purely with bash scripting.
- Host: GitHub
- URL: https://github.com/jv-k/ver-bump
- Owner: jv-k
- License: mit
- Created: 2020-11-27T00:54:05.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-04T17:52:41.000Z (4 months ago)
- Last Synced: 2024-10-02T00:11:02.714Z (about 1 month ago)
- Topics: automation, bump-version, bumpversion, changelog, git, git-branch-develop, package, publish, release, release-automation, semver, ver-bump, version, version-bump, versioning
- Language: Shell
- Homepage: https://www.npmjs.com/package/ver-bump
- Size: 698 KB
- Stars: 22
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ver-bump
A fully automated handy CLI utility that takes care of releasing GitHub software projects, written in 100% pure bash.
[![!#/bin/bash](https://img.shields.io/badge/-%23!%2Fbin%2Fbash-1f425f.svg?logo=image%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICA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Z%2FCzAAHsJVbwXYFFEAAAAASUVORK5CYII%3D)](https://www.gnu.org/software/bash/) [![CI](https://github.com/jv-k/ver-bump/actions/workflows/ci.yml/badge.svg)](https://github.com/jv-k/ver-bump/actions/workflows/ci.yml) [![CodeFactor](https://www.codefactor.io/repository/github/jv-k/ver-bump/badge)](https://www.codefactor.io/repository/github/jv-k/ver-bump) [![npm version](https://badge.fury.io/js/ver-bump.svg)](https://badge.fury.io/js/ver-bump) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
## Highlights 📦🚀
It does several things that are typically required for releasing a Git repository:
- Create a release branch from your current branch (should be a feature or develop branch, following the [Git branch-based workflow](https://nvie.com/posts/a-successful-git-branching-model/), and [tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging) the release
- Enforces [Semantic Versioning](https://semver.org/) specification
- Avoid potential mistakes associated with manual releases, such as forgetting a step
- Create and update a changelog file automatically
- Pushes release to a remote
- Leaves merging the release branch to the development branch to the user## Table of Contents
Details
- [Release Steps 👣](#release-steps-)
- [Verify + Prepare Release](#verify--prepare-release)
- [Create Release](#create-release)
- [Release Steps: In detail 🔎](#release-steps-in-detail-)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Pre-requisites](#pre-requisites)
- [CLI](#cli)
- [Options](#options)
- [Example](#example)
- [Tests](#tests)
- [Contributing](#contributing)
- [License](#license)## Release Steps 👣
The command `ver-bump` will execute the following steps:
### Verify + Prepare Release
- Verify some commits exist
- Selects a semantic version number for the release branch & tag
- Increments / suggests a semantic version number for the release and its tag
- Checks to see a tagged release with the chosen version already exists### Create Release
- Bump version number in `package.json`
- Write `CHANGELOG.md`
- Create release branch
- Commit changes to files made by this script
- Create a Git tag
- Push release branch + tag to remote## Release Steps: In detail 🔎
Step
Description
Verify + Prepare Release
Process user arguments
Check and store CLI arguments supplied by user for later processing.
Check commits
Verify some commits exist for release.
Determine Release Version
If<package.json>
doesn't exist, warn + exit.
If-v
option is
specified, set version from that.
Or, grab from version frompackage.json
.
Suggest
incremented version number in the form ofMAJOR.MINOR.PATCH
(incrementingPATCH
), as
per Semver 2.0.0.
Give the user the option to modify/confirm suggested version bump.
Check branch exist
Ensure a release branch with the chosen version number doesn't already exist, if so exit.
Check tag exists
Ensure a tag with the chosen version number doesn't exist, and exit if it does.
Create Release
Bump version number
Update semantic version number inpackage.json
+ stages changes.
Generate changelog
Commits since the last release are automatically added toCHANGELOG.md
, as well as new commit
messages for files modified by this script itself. Stages changes for commit action later.
Create release branch
Create a branch with the namerelease-MAJOR.MINOR.PATCH
and switch to it (following the Git branch-based
workflow).
Commit changed files
Commits changes topackage.json
and CHANGELOG.md` (staged in the previous steps) to the release
branch.
Create Git tag
Create a Git tag referencing the new release version.
Push
Optionally, push the release branch to origin.
## Requirements
In order to use `ver-bump` you need:
- To host your project code in a Git repository
- Have Git installed in your environment
- Have `npm` and `node` installed## Installation
Install the script globally via npm, and use it in any local Git repository to release your project:
```sh
$ npm install -g ver-bump
```## Usage
### Pre-requisites
- Make sure you have `package.json` file in your project and it contains a `"version": "x.x.x"` parameter
- You have done some work and have some existing commits
- You have the ability to push to your Git remote via the Git CLI### CLI
```sh
$ ver-bump [-v ] [-m ] [-j ] [-j ].. [-n] [-p] [-b] [-h]
```## Options
```text
-v Specify a manual version number
-m Custom release message
-f Update version number inside JSON files.
* For multiple files, add a separate -f option for each one,
* For example:
./ver-bump.sh -f src/plugin/package.json -f composer.json
-p Push commits to remote repository, eg `-p Origin`
-n Turns off automatic commit
* You may want to do that yourself, for example.
-b Don't create automatic `release-` branch.
-c Disable updating CHANGELOG.md automatically with new commits
since last release tag.
-l Pause enabled for amending CHANGELOG.md
-h Show help message.
```## Example
> This example assumes that a `package.json` contains `version: "1.0.0"`, and the user is working in the branch to be released with pre-existing un-released commits.
1. This will create a new Git branch called `release-1.0.1` and a Git tag named `v1.0.1`:
```sh
$ ver-bump
```Output:
```text
Current version read from file: 1.0.0Enter a new version number or press to use [1.0.1]:
––––––
✅ Updated file from 1.0.0 -> 1.0.1
✅ Updated [CHANGELOG.md] file
Make adjustments to [CHANGELOG.md] if required now. Press to continue.
Creating new release branch...
✅ Switched to branch 'release-1.0.1'
M CHANGELOG.md
M package.jsonCommitting...
✅ [release-1.0.1 ace8b1e] Updated package.json, Updated CHANGELOG.md, Bumped 1.0.0 –> 1.0.1
2 files changed, 9 insertions(+), 1 deletion(-)✅ Added GIT tag
Push tags to ? [N/y]: n
––––––
✅ Bumped 1.0.0 –> 1.0.1
🏁 Done!
```2. After checking out the changes in the branch and confirming them, test the release, and push the release branch to your remote if you didn't choose to push it automatically. Alternatively, use `$ ver-bump -p origin` to bypass the prompt and push the release branch anyway to the remote automatically.
3. If your code checks out, then open a Pull Request to merge the release branch into your `develop` or main branch.You can merge the release branch into your development branch or main branch like this, without fast-forwarding so that the branch topology is preseved as you're merging in a release branch that hasn't diverged (apart from new changes to `CHANGELOG.md` and `package.json`) and you want to ensure it's clearly evident when reading the history that a merge was performed, as opposed to a fast-forward merge, where new commits performed by the merge will become descendents of the last commit before the merge.
A release branch shouldn't normally diverge from the branch it was created during the time `ver-bump` is operating, so a non-fastforward should be possible instead of a normal merge, which would simply looks like a new commit was made to the main or development branch.
```sh
$ git checkout develop # Switch to development branch from the new release branch$ git merge --no-ff release-1.0.1 # Merge the new release branch to your development branch
```## Tests
This project uses [bats](https://github.com/bats-core/bats-core) to test the functionality of ver-bump.
To run the tests, first install the pre-requisites:
Linux/MacOS:
```sh
$ npm run tests:install
```Windows:
```sh
$ npm run tests:install:windows
```And finally, run the test suite:
```sh
$ npm run tests:run
```Output:
```sh
ver-bump.bats
✓ can run script
✓ process-arguments: -h: display help message
✓ process-arguments: -v: fail when not supplying version
✓ process-arguments: -v x.x.x: succeed when supplying version
✓ process-arguments: -m: fail when not supplying release note
✓ process-arguments: -m : succeed when supplying release note
✓ process-arguments: -f: fail when not supplying filenames
✓ process-arguments: -f : succeed with multiple filenames
✓ process-arguments: -p: fail when not supplying push destination
✓ process-arguments: -p : succeed when supplying a destination
✓ process-arguments: -n: set flag to prevent committing at the end
✓ process-arguments: -b: set flag to disable creating a release branch
✓ process-arguments: -c: set flag to disable creating/updating CHANGELOG.md
✓ process-arguments: -l: set flag to enable pausing after CHANGELOG.md is created
✓ process-arguments: fail on not-existing argument
✓ set-v-suggest: increments version
✓ set-v-suggest: fails to increments non SemVer version
✓ process-version: fail on entering non-SemVer input
✓ process-version: patch of the version from json file should be bumped +1
✓ do-packagefile-bump: can bump version in package.json + lock file
✓ bump-json-files: can bump version in a json file
✓ bump-json-files: can fail bumping a json file when a version already exists in file
✓ bump-json-files: can fail bumping a json file when no version found inside it
✓ check-branch-notexist: can detect branch DOES exist
✓ check-branch-notexist: can confirm branch DOES'NT exist
✓ do-branch: can create a release branch
✓ do-tag: create a tag
✓ check-tag-exists: check doesn't exist
✓ check-tag-exists: check it exists
✓ do-changelog: can create a CHANGELOG.md30 tests, 0 failures
```## Contributing
I'd love you to contribute to `@jv-k/ver-bump`, [pull requests](https://github.com/jv-k/ver-bump/issues/new/choose) are welcome for submitting issues and bugs!
## License
The scripts and documentation in this project are released under the [MIT license](https://github.com/jv-k/ver-bump/blob/master/LICENSE).