#!/usr/bin/env bash # # Derives a valid npm semver version from the Git tag produced by # `git describe` and writes it into the root package.json. # # Examples of the conversion: # 2.14.0 -> 2.14.0 # 2.14.0-RC1 -> 2.14.0-rc.1 # 2.14.0-RC1-140-g9f2ca9965 -> 2.14.0-rc.1.140 # 2.14.0-140-g9f2ca9965 -> 2.14.1-dev.140 # # The last case (commits after a release tag) bumps the patch level so # the resulting semver sorts higher than the release. set -euo pipefail raw=$(git describe --tags --match "*.*.*") # Parse: ..[-