npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ver-bump

v1.1.8

Published

This script automates bumping the git software project's version using automation. It does several things that are typically required for releasing a Git repository, like git tagging, automatic updating of CHANGELOG.md, and incrementing the version number

Downloads

173

Readme

ver-bump

A fully automated handy CLI utility that takes care of releasing GitHub software projects, written in 100% pure bash.

!#/bin/bash CI CodeFactor npm version License: MIT

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, and tags the release
  • Enforces Semantic Versioning 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

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 🔎

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:

$ 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

$ ver-bump [-v <version no.>] [-m <release message>] [-j <file1>] [-j <file2>].. [-n] [-p] [-b] [-h]

Options

-v <version number>     Specify a manual version number
-m <release message>    Custom release message
-f <filename.json>      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 <repository alias>   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-<version>` 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:

    $ ver-bump

    Output:

    Current version read from <package.json> file: 1.0.0
    
    Enter a new version number or press <enter> to use [1.0.1]: <pressed enter>
    
    ––––––
    
    ✅ Updated file <package.json> from 1.0.0 -> 1.0.1
    
    ✅ Updated [CHANGELOG.md] file
    
    Make adjustments to [CHANGELOG.md] if required now. Press <enter> to continue.
    
    Creating new release branch...
    
    ✅ Switched to branch 'release-1.0.1'
    M CHANGELOG.md
    M package.json
    
    Committing...
    
    ✅ [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 <origin>? [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.

    $ 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 to test the functionality of ver-bump.

To run the tests, first install the pre-requisites:

Linux/MacOS:

$ npm run tests:install

Windows:

$ npm run tests:install:windows

And finally, run the test suite:

$ npm run tests:run

Output:

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 <note>: succeed when supplying release note
 ✓ process-arguments: -f: fail when not supplying filenames
 ✓ process-arguments: -f <filename.json>: succeed with multiple filenames
 ✓ process-arguments: -p: fail when not supplying push destination
 ✓ process-arguments: -p <repo destination>: 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.md

30 tests, 0 failures

Contributing

I'd love you to contribute to @jv-k/ver-bump, pull requests are welcome for submitting issues and bugs!

License

The scripts and documentation in this project are released under the MIT license.