Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep version of magics package consistent in future releases #745

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .jupyter-releaser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
29 changes: 24 additions & 5 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
#!/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

# 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 \
--force-publish \
-y \
$1 \
"$1" \
) || exit 1

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
Loading