From a3e3c0b01f2a00c9ee1c5c58b771ff64d7442c0b Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 11:10:08 -0700 Subject: [PATCH] handle non-exact version specifiers like 'minor' --- scripts/bump-version.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 6ac435fb1..15a2df3d0 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -1,10 +1,13 @@ #!/bin/bash -# script that bumps version for all projects regardless of whether they were -# changed since last release. needed because `lerna version` only bumps versions for projects -# listed by `lerna changed` by default. +# Script used by Jupyter Releaser that bumps the version of all packages to the +# one provided in `$1`. This script requires `jq` to be installed. # -# see: https://github.com/lerna/lerna/issues/2369 +# This script is necessary because a) `lerna version` only bumps versions for +# projects listed by `lerna changed` by default [1], and b) the version in +# `packages/jupyter-ai/pyproject.toml` needs to be bumped as well. +# +# [1]: https://github.com/lerna/lerna/issues/2369 (npx -p lerna@6.4.1 -y lerna version \ --no-git-tag-version \ @@ -15,10 +18,11 @@ ) || exit 1 if [[ "$PWD" == *packages/jupyter-ai ]]; then + version=$(cat package.json | jq -r '.version') # bump dependency in jupyter-ai to rely on current version of jupyter-ai-magics # -E : use extended regex to allow usage of `+` symbol # -i.bak : edit file in-place, generating a backup file ending in `.bak`, which we delete on success # while confusing, this unfortunately is the only way to edit in-place on both macOS and Linux # reference: https://stackoverflow.com/a/44864004 - sed -E -i.bak "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$1/" pyproject.toml && rm pyproject.toml.bak + sed -E -i.bak "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$version/" pyproject.toml && rm pyproject.toml.bak fi