From 7d60f724bdc9da3dc16e3d4747d0d9ad335a8618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Thu, 19 Nov 2026 14:04:57 +0100 Subject: [PATCH] Add a version bump script for releases Creates the release- branch, sets the version in package.json and turns the Unreleased CHANGELOG.md section into the new version's entry (or adds an empty one). It does not commit; it prints BRANCH_NAME:. --- release-automation/bump-version.sh | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 release-automation/bump-version.sh diff --git a/release-automation/bump-version.sh b/release-automation/bump-version.sh new file mode 100755 index 0000000..a1f2b23 --- /dev/null +++ b/release-automation/bump-version.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euo pipefail + +# Called by the release automation during a release. +# Creates a release branch and bumps the package version without committing; +# the caller commits, pushes and opens the PR. Must print BRANCH_NAME:. +# +# Usage: ./bump-version.sh + +VERSION="${1:-}" + +if [ -z "$VERSION" ]; then + echo "Usage: $0 " + exit 1 +fi + +BRANCH_NAME="release-$VERSION" +git checkout -b "$BRANCH_NAME" + +npm version "$VERSION" --no-git-tag-version +echo "Updated package.json to $VERSION" + +# Turn the "Unreleased" section into this version's entry, or add an empty entry +# under the title when there is none. perl -pi works the same with GNU and BSD tools. +export VERSION +if grep -q '^## Unreleased$' CHANGELOG.md; then + perl -pi -e 's/^## Unreleased$/## $ENV{VERSION}/ if !$done++ && /^## Unreleased$/' CHANGELOG.md + echo "Renamed the Unreleased CHANGELOG.md section to $VERSION" +elif ! grep -q "^## $VERSION\$" CHANGELOG.md; then + perl -0pi -e 's/\A(# Changelog\n\n)/$1## $ENV{VERSION}\n\n- TODO: describe the changes in this release.\n\n/' CHANGELOG.md + echo "Added a CHANGELOG.md entry for $VERSION" +fi + +echo "BRANCH_NAME:$BRANCH_NAME"