setver: Package (semver) version management for bash/PHP/Node

When you’re creating software packages that will be used by other people, you need to get your versioning in order. For PHP libraries, this means: both the version number in composer.json as well as the git tag for Github/Bitbucket. For node.js projects, the version is kept by npm in package.json. It was always too easy to make small mistakes. So I decided to make a bash script <strong>semver.sh</strong> to manage it for me.

https://github.com/pforret/setver

This works for PHP/Composer projects, Node/NPM projects and Bash projects. At the least it will get/set your git tags (and push them to Github/Bitbucket), but if present, it will also first set versions on composer.json or package.json . There’s also the option to use a VERSION.md file, that will always contain the version number.

For PHP packages: creating and pushing the git tag will also trigger Packagist (the PHP package manager repository) to update the package version. It’s also important that the composer.json version and the git tag version are always the same.

Semver.sh allows you to do:

The semver.sh then executes:

➜  setver.sh new minor

> version 1.0.3 -> 1.1.0

> set version in composer.json

> commit and push changed files

[master 1261456] semver.sh: set version to 1.1.0

> set git version tag

> push tags to git@github.com:<username/package>.git

 * [new tag]         v1.1.0 -> v1.1.0

Next to that, semver.sh also allows to

What is Semver?

Semver -or Sematic Versioning- is a version labeling convention that requires software to have a version number of the type <major>.<minor>.<patch> (e.g. 1.4.15). This is how you increment versions in semver:

There are the option in semver to use alpha/beta/pre-release versions, but I’m not using that for now.

In order to keep the script small, I just used a subset of library functions from bashew.

💬 repo 🏷 bash 🏷 composer 🏷 node 🏷 nodejs 🏷 npm 🏷 package 🏷 php 🏷 semver 🏷 versioning