Skip to content

Commit

Permalink
Prepare for Jupyter Releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart authored and jtpio committed Nov 17, 2021
1 parent 6dff84d commit a3501f0
Show file tree
Hide file tree
Showing 16 changed files with 268 additions and 14 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Check Release
on:
push:
branches: ["master"]
pull_request:
branches: ["*"]

permissions:
contents: write

jobs:
check_release:
timeout-minutes: 720
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group: [check_release, link_check]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: "x64"
- name: Install node
uses: actions/setup-node@v2
with:
node-version: "14.x"
# Cache yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-pip-
- name: Cache checked links
if: ${{ matrix.group == 'link_check' }}
uses: actions/cache@v2
with:
path: ~/.cache/pytest-link-check
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/*.md', '**/*.rst') }}-md-links
restore-keys: |
${{ runner.os }}-linkcheck-
- name: Upgrade packaging dependencies
run: |
pip install --upgrade pip setuptools wheel --user
- name: Check Release
if: ${{ matrix.group == 'check_release' }}
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
env:
RH_VERSION_SPEC: next
- name: Check Links
if: ${{ matrix.group == 'link_check' }}
uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1
- name: Upload Distributions
uses: actions/upload-artifact@v2
with:
name: ipywidgets-jupyter-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
3 changes: 3 additions & 0 deletions docs/source/changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A summary of changes in ipywidgets. For more detailed information, see the issues and pull requests for the appropriate milestone on [GitHub](https://github.com/jupyter-widgets/ipywidgets).

<!-- <START NEW CHANGELOG ENTRY> -->

## [8.0](https://github.com/jupyter-widgets/ipywidgets/releases/tag/v8.0) (not released yet)

See the [ipywidgets
Expand Down Expand Up @@ -58,6 +60,7 @@ milestone on GitHub for the full list of pull requests and issues closed.
* Removed deprecated signature of the `register` decorator ([#2695](https://github.com/jupyter-widgets/ipywidgets/pull/2695))
* Remove deprecated `handle_kernel` alias ([#2694](https://github.com/jupyter-widgets/ipywidgets/pull/2694))

<!-- <END NEW CHANGELOG ENTRY> -->

## 7.6

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ See the [examples](docs/source/examples.md) section of the documentation. The wi

## Change log

[Change log](docs/source/changelog.md)
[Change log](CHANGELOG.md)

### Version Compatibility with Front-End Clients

Expand Down
8 changes: 8 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
#

import os.path as osp
import shutil

# -- source files and parsers -----------------------------------

Expand Down Expand Up @@ -135,3 +137,9 @@
'includehidden': True,
'titles_only': False
}


def setup(app):
HERE = osp.abspath(osp.dirname(__file__))
dest = osp.join(HERE, 'changelog.md')
shutil.copy(osp.join(HERE, '..', '..', 'CHANGELOG.md'), dest)
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "@jupyter-widgets/root",
"version": "0.1.0",
"private": true,
"workspaces": [
"packages/*",
Expand All @@ -19,11 +21,7 @@
"lint:check": "yarn run prettier:check && yarn run eslint:check",
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
"prettier:check": "prettier --ignore-path .gitignore --check \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
"publish": "yarn run clean && yarn run build && lerna publish --pre-dist-tag next from-git",
"sort-package-json": "lerna exec --parallel sort-package-json && sort-package-json",
"update-dependency": "update-dependency --lerna",
"updated": "lerna updated",
"version": "yarn run clean && yarn run build && lerna version --no-push -m \"Bump version\" "
"sort-package-json": "lerna exec --parallel sort-package-json && sort-package-json"
},
"husky": {
"hooks": {
Expand Down
1 change: 0 additions & 1 deletion packages/base-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"build:test": "tsc --build test && webpack --config test/webpack.conf.js",
"clean": "npm run clean:src",
"clean:src": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepublish": "npm run clean && npm run build",
"test": "npm run test:unit",
"test:coverage": "npm run build:test && webpack --config test/webpack-cov.conf.js && karma start test/karma-cov.conf.js",
"test:unit": "npm run test:unit:firefox && npm run test:unit:chrome",
Expand Down
1 change: 0 additions & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"build:test": "tsc --build test && webpack --config test/webpack.conf.js",
"clean": "npm run clean:src",
"clean:src": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepublish": "npm run clean && npm run build",
"test": "npm run test:unit",
"test:coverage": "npm run build:test && webpack --config test/webpack-cov.conf.js && karma start test/karma-cov.conf.js",
"test:unit": "npm run test:unit:firefox && npm run test:unit:chrome",
Expand Down
1 change: 0 additions & 1 deletion packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"build:test": "tsc --build test && webpack --config test/webpack.conf.js",
"clean": "npm run clean:src",
"clean:src": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepublish": "npm run clean && npm run build",
"test": "npm run test:unit",
"test:coverage": "npm run build:test && webpack --config test/webpack-cov.conf.js && karma start test/karma-cov.conf.js",
"test:unit": "npm run test:unit:firefox && npm run test:unit:chrome",
Expand Down
1 change: 0 additions & 1 deletion packages/html-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"build:src": "tsc --build",
"build:test": "tsc --build test && webpack --config test/webpack.conf.js",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo && rimraf dist",
"prepublish": "npm run clean && npm run build",
"test": "npm run test:unit",
"test:unit": "npm run test:unit:firefox && npm run test:unit:chrome",
"test:unit:chrome": "npm run test:unit:default -- --browsers=Chrome",
Expand Down
1 change: 0 additions & 1 deletion packages/output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"build": "npm run build:src",
"build:src": "tsc --build",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepublish": "npm run clean && npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
Expand Down
30 changes: 29 additions & 1 deletion python/ipywidgets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,32 @@
# These are the assumed default build requirements from pip:
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = ["setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[tool.check-manifest]
ignore = [".*"]

[tool.tbump.version]
current = "8.0.0a6"
regex = '''
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "ipywidgets/_version.py"

[tool.jupyter-releaser]
skip = ["check-links", "check-manifest"]

[tool.jupyter-releaser.hooks]
before-prep-git = ["python -m pip install -U jupyterlab~=3.0"]
before-bump-version = ["python -m pip install bump2version", "yarn"]

[tool.jupyter-releaser.options]
version-cmd = "python scripts/bump-version.py --force"
python_packages = [".", "jupyterlab_widgets", "widgetsnbextension"]
1 change: 0 additions & 1 deletion python/jupyterlab_widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install:extension": "jlpm run build",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
Expand Down
17 changes: 17 additions & 0 deletions python/jupyterlab_widgets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,20 @@ npm = ["jlpm"]

[tool.check-manifest]
ignore = ["jupyterlab_widgets/labextension/**", "yarn.lock", ".*", "package-lock.json"]

[tool.tbump.version]
current = "2.0.0a3"
regex = '''
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "jupyterlab_widgets/_version.py"

[tool.jupyter-releaser]
skip = ["check-links"]
1 change: 0 additions & 1 deletion python/widgetsnbextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"scripts": {
"build": "webpack",
"clean": "rimraf widgetsnbextension/static",
"prepublish": "npm run clean && npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
Expand Down
17 changes: 17 additions & 0 deletions python/widgetsnbextension/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ npm = ["yarn"]

[tool.check-manifest]
ignore = ["widgetnbextension/static/**", "yarn.lock", ".*", "package-lock.json"]

[tool.tbump.version]
current = "4.0.0a4"
regex = '''
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "widgetsnbextension/_version.py"

[tool.jupyter-releaser]
skip = ["check-links"]
110 changes: 110 additions & 0 deletions scripts/bump-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.import click

# Heavily inspired by:
# - https://github.com/jupyterlab/jupyterlab/blob/master/buildutils/src/bumpversion.ts
# - https://github.com/jupyterlab/retrolab/blob/main/buildutils/src/release-bump.ts

import click
from jupyter_releaser.util import is_prerelease, get_version, run


OPTIONS = ["major", "minor", "release", "build"]


def patch(force=False):
version = get_version()
if is_prerelease(version):
raise Exception("Can only make a patch release from a final version")

run("bumpversion patch", quiet=True)
# switches to alpha
run("bumpversion release --allow-dirty", quiet=True)
# switches to beta
run("bumpversion release --allow-dirty", quiet=True)
# switches to rc.
run("bumpversion release --allow-dirty", quiet=True)
# switches to final.

# Version the changed
cmd = "yarn run lerna version patch --no-push --force-publish --no-git-tag-version"
if force:
cmd += " --yes"
run(cmd)


def update(spec, force=False):
prev = get_version()

# Make sure we have a valid version spec.
if spec not in OPTIONS:
raise Exception(f"Version spec must be one of: {OPTIONS}")

is_final = not is_prerelease(prev)

if is_final and spec == "release":
raise Exception('Use "major" or "minor" to switch back to alpha release')

if is_final and spec == "build":
raise Exception("Cannot increment a build on a final release")

# If this is a major release during the alpha cycle, bump
# just the Python version.
if "a" in prev and spec == "major":
run(f"bumpversion {spec}")
return

# Determine the version spec to use for yarn.
version = "preminor"
if spec == "build":
version = "prerelease"
# a -> b
elif spec == "release" and "a" in prev:
version = "prerelease --preid beta"
# b -> rc
elif spec == "release" and "b" in prev:
version = "prerelease --preid rc"
# rc -> final
elif spec == "release" and "c" in prev:
version = "patch"
if version == "preminor":
version += " --preid alpha"

cmd = f"yarn run lerna version --no-push --force-publish --no-git-tag-version {version}"
if force:
cmd += " --yes"

# For a preminor release, we bump 10 minor versions so that we do
# not conflict with versions during minor releases of the top level package.
if version == "preminor":
for i in range(10):
run(cmd)
else:
run(cmd)

# Bump the version.
run(f"bumpversion {spec} --allow-dirty")


@click.command()
@click.option("--force", default=False, is_flag=True)
@click.argument("spec", nargs=1)
def bump(force, spec):
status = run("git status --porcelain").strip()
if len(status) > 0:
raise Exception("Must be in a clean git state with no untracked files")

prev = get_version()
is_final = not is_prerelease(prev)
if spec == "next":
spec = "patch" if is_final else "build"

if spec == "patch":
patch(force)
return

update(spec, force)


if __name__ == "__main__":
bump()

0 comments on commit a3501f0

Please sign in to comment.