From fc264bd2145571174d124697410c273df976c132 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 09:28:00 -0700 Subject: [PATCH 1/6] synchronize package versions in future releases --- scripts/bump-version.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 900211be9..d33bb7d84 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -11,5 +11,10 @@ --no-push \ --force-publish \ -y \ - $1 \ + "$1" \ ) || exit 1 + +# bump dependency in jupyter-ai to rely on current version of jupyter-ai-magics +# -E : use extended regex to allow usage of `+` symbol +# -i '' : modify file in-place +sed -E -i '' "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$1/" packages/jupyter-ai/pyproject.toml From fccf4ef90941580bde9dbca947e05e88ad9d071a Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 09:48:58 -0700 Subject: [PATCH 2/6] only sed if PWD is packages/jupyter-ai --- scripts/bump-version.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index d33bb7d84..dc3f7413f 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -14,7 +14,9 @@ "$1" \ ) || exit 1 -# bump dependency in jupyter-ai to rely on current version of jupyter-ai-magics -# -E : use extended regex to allow usage of `+` symbol -# -i '' : modify file in-place -sed -E -i '' "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$1/" packages/jupyter-ai/pyproject.toml +if [[ "$PWD" == *packages/jupyter-ai ]]; then + # bump dependency in jupyter-ai to rely on current version of jupyter-ai-magics + # -E : use extended regex to allow usage of `+` symbol + # -i '' : modify file in-place + sed -E -i '' "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$1/" pyproject.toml +fi From 599ece0f3ebab92cee59ebf04cdaf21fdaa1db69 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 09:56:46 -0700 Subject: [PATCH 3/6] make script compatible in Linux & macOS --- scripts/bump-version.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index dc3f7413f..6ac435fb1 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -17,6 +17,8 @@ if [[ "$PWD" == *packages/jupyter-ai ]]; then # bump dependency in jupyter-ai to rely on current version of jupyter-ai-magics # -E : use extended regex to allow usage of `+` symbol - # -i '' : modify file in-place - sed -E -i '' "s/jupyter_ai_magics.=[0-9]+\.[0-9]+\.[0-9]+/jupyter_ai_magics==$1/" pyproject.toml + # -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 fi From a3e3c0b01f2a00c9ee1c5c58b771ff64d7442c0b Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 11:10:08 -0700 Subject: [PATCH 4/6] 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 From 029fc45299ee399a8b85a15f1e7f4aeb4605d630 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 11:27:00 -0700 Subject: [PATCH 5/6] only run script once in releaser workflows --- scripts/bump-version.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 15a2df3d0..756dd5924 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -9,6 +9,14 @@ # # [1]: https://github.com/lerna/lerna/issues/2369 +# Jupyter Releaser runs this script once per package in the monorepo, but we +# should only run this script once in `packages/jupyter-ai`. +if [[ "$PWD" != *packages/jupyter-ai ]]; then + echo "Skipping this dir as this script should only be run from 'packages/jupyter-ai'." + echo "CWD: $PWD" + exit 0 +fi + (npx -p lerna@6.4.1 -y lerna version \ --no-git-tag-version \ --no-push \ @@ -17,12 +25,10 @@ "$1" \ ) || 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==$version/" pyproject.toml && rm pyproject.toml.bak -fi +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==$version/" pyproject.toml && rm pyproject.toml.bak From a400240bf89b84582ca33e7ab89382a6aa4fc0f7 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Thu, 25 Apr 2024 12:33:07 -0700 Subject: [PATCH 6/6] skip pyproject check when releasing --- .jupyter-releaser.toml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.jupyter-releaser.toml b/.jupyter-releaser.toml index ed5f9f4ec..0f57ba968 100644 --- a/.jupyter-releaser.toml +++ b/.jupyter-releaser.toml @@ -2,15 +2,17 @@ before-build-npm = [ "python -m pip install jupyterlab~=4.0", "jlpm", - "jlpm build:prod" -] -before-build-python = [ - "jlpm clean:all" + "jlpm build:prod", ] +before-build-python = ["jlpm clean:all"] [options] version-cmd = "../../scripts/bump-version.sh" python_packages = [ "packages/jupyter-ai:jupyter-ai", - "packages/jupyter-ai-magics:jupyter-ai-magics" + "packages/jupyter-ai-magics:jupyter-ai-magics", ] + +# this is set to skip validation of pyproject.toml by default +# otherwise, check-release fails because the bumped dependency on `jupyter-ai-magics` does not exist in PyPI +pydist_extra_check_cmds = []