Skip to content

Commit 11634d0

Browse files
committed
Set up releaser
1 parent 1256224 commit 11634d0

9 files changed

+221
-21
lines changed

.github/workflows/check-release.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check Release
2+
on:
3+
push:
4+
branches: ["master", "*"]
5+
pull_request:
6+
branches: ["*"]
7+
8+
jobs:
9+
check_release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Base Setup
15+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
16+
- name: Check Release
17+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Upload Distributions
21+
uses: actions/upload-artifact@v3
22+
with:
23+
name: nbdime-releaser-dist-${{ '{{ github.run_number }}' }}
24+
path: .jupyter_releaser_checkout/dist

.github/workflows/enforce-label.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Enforce PR label
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, edited, synchronize]
6+
jobs:
7+
enforce-label:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
steps:
12+
- name: enforce-triage-label
13+
uses: jupyterlab/maintainer-tools/.github/actions/enforce-label@v1

.github/workflows/prep-release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Step 1: Prep Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version_spec:
6+
description: "New Version Specifier"
7+
default: "next"
8+
required: false
9+
branch:
10+
description: "The branch to target"
11+
required: false
12+
post_version_spec:
13+
description: "Post Version Specifier"
14+
required: false
15+
since:
16+
description: "Use PRs with activity since this date or git reference"
17+
required: false
18+
since_last_stable:
19+
description: "Use PRs with activity since the last stable git tag"
20+
required: false
21+
type: boolean
22+
jobs:
23+
prep_release:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
27+
28+
- name: Prep Release
29+
id: prep-release
30+
uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
31+
with:
32+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
33+
version_spec: ${{ github.event.inputs.version_spec }}
34+
post_version_spec: ${{ github.event.inputs.post_version_spec }}
35+
branch: ${{ github.event.inputs.branch }}
36+
since: ${{ github.event.inputs.since }}
37+
since_last_stable: ${{ github.event.inputs.since_last_stable }}
38+
39+
- name: "** Next Step **"
40+
run: |
41+
echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"

.github/workflows/publish-release.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Step 2: Publish Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: "The target branch"
7+
required: false
8+
release_url:
9+
description: "The URL of the draft GitHub release"
10+
required: false
11+
steps_to_skip:
12+
description: "Comma separated list of steps to skip"
13+
required: false
14+
15+
jobs:
16+
publish_release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
# This is useful if you want to use PyPI trusted publisher
20+
# and NPM provenance
21+
id-token: write
22+
steps:
23+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
24+
25+
- name: Populate Release
26+
id: populate-release
27+
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
28+
with:
29+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
30+
branch: ${{ github.event.inputs.branch }}
31+
release_url: ${{ github.event.inputs.release_url }}
32+
steps_to_skip: ${{ github.event.inputs.steps_to_skip }}
33+
34+
- name: Finalize Release
35+
id: finalize-release
36+
env:
37+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2
39+
with:
40+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
41+
release_url: ${{ steps.populate-release.outputs.release_url }}
42+
43+
- name: "** Next Step **"
44+
if: ${{ success() }}
45+
run: |
46+
echo "Verify the final release"
47+
echo ${{ steps.finalize-release.outputs.release_url }}
48+
49+
- name: "** Failure Message **"
50+
if: ${{ failure() }}
51+
run: |
52+
echo "Failed to Publish the Draft Release Url:"
53+
echo ${{ steps.populate-release.outputs.release_url }}

docs/source/installing.rst

+2-18
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ and nbdime's web-based viewers depend on the following Node.js packages:
4444

4545
- codemirror
4646
- json-stable-stringify
47-
- jupyter-js-services
4847
- jupyterlab
4948
- lumino
5049

@@ -90,31 +89,16 @@ Installing Jupyter extensions
9089
If you want to use the development version of the notebook and lab extensions,
9190
you will also have to run the following commands after the pip dev install::
9291

93-
jupyter serverextension enable --py nbdime --sys-prefix # if developing for jupyter notebook
94-
9592
jupyter server extension enable nbdime # if developing for jupyter lab or nbclassic
9693

97-
jupyter nbextension install --py nbdime --sys-prefix [--sym-link]
98-
jupyter nbextension enable --py nbdime --sys-prefix
99-
100-
jupyter labextension link ./packages/nbdime --no-build
101-
jupyter labextension install ./packages/labextension
94+
jupyter labextension develop --overwrite .
10295

10396

10497
If you do any changes to the front-end code, run :command:`npm run build` from the
105-
repoistory root to rebuild the extensions. If you make any changes to the
98+
repository root to rebuild the extensions. If you make any changes to the
10699
server extension, you will have to restart the server to pick up the changes!
107100

108101

109-
.. note::
110-
111-
The optional ``--sym-link`` flag for :command:`jupyter nbextension install` allows
112-
the notebook frontend to pick up a newly built version of the extension on
113-
a page refresh. For details on the other flags, see
114-
:doc:`extensions`.
115-
116-
117-
118102
.. toctree::
119103
:hidden:
120104

docs/source/nodevenv.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The following steps will: create a virtualenv, named ``myenv``, in the current
55
directory; activate the virtualenv; and install npm inside the virtualenv
66
using :command:`nodeenv`::
77

8-
python3 -m venv myenv # For Python 2: python2 -m virtualenv myenv
8+
python -m venv myenv
99
source myenv/bin/activate
1010
pip install nodeenv
1111
nodeenv -p
@@ -15,7 +15,7 @@ dependencies using :command:`pip`.
1515

1616
For example with Python 3.5, the steps with output are::
1717

18-
$ python3 -m venv myenv
18+
$ python -m venv myenv
1919
$ source myenv/bin/activate
2020
(myenv) $ pip install nodeenv
2121
Collecting nodeenv

pyproject.toml

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
[build-system]
22
requires = ["jupyterlab~=4.0", "setuptools>=40.8.0", "wheel"]
33
build-backend = "setuptools.build_meta"
4+
5+
[tool.jupyter-releaser.options]
6+
version-cmd = "python scripts/bump_version.py --force"
7+
8+
[tool.jupyter-releaser.hooks]
9+
before-bump-version = [
10+
"npm install"
11+
]

scripts/bump_version.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
import argparse
5+
import json
6+
import shlex
7+
import sys
8+
from pathlib import Path
9+
from subprocess import check_output, run
10+
11+
from packaging.version import parse
12+
13+
LERNA_CMD = "npm run lerna version --no-push --force-publish --no-git-tag-version"
14+
15+
16+
def install_dependencies() -> None:
17+
pkgs = []
18+
try:
19+
import hatch
20+
except ImportError:
21+
pkgs.append("hatch")
22+
23+
if pkgs:
24+
run([sys.executable, "-m", "pip", "install"] + pkgs)
25+
26+
27+
def bump(force: bool, spec: str) -> None:
28+
install_dependencies()
29+
30+
HERE = Path(__file__).parent.parent.resolve()
31+
output = check_output(
32+
shlex.split("git status --porcelain"), cwd=HERE, encoding="utf-8"
33+
)
34+
if len(output) > 0:
35+
raise Exception("Must be in a clean git state with no untracked files")
36+
37+
run(
38+
[sys.executable, "-m", "hatch", "version", spec], cwd=HERE, encoding="utf-8", check=True
39+
)
40+
41+
version = parse(
42+
# Output maybe multi-lines if build dependencies needs to be installed.
43+
check_output(
44+
[sys.executable, "-m", "hatch", "version"], cwd=HERE, encoding="utf-8"
45+
).strip("\n").split("\n")[-1]
46+
)
47+
48+
# convert the Python version
49+
js_spec = "prerelease" if spec in ["alpha", "a", "beta", "b", "rc"] else spec
50+
51+
# bump the JS packages
52+
lerna_cmd = f"{LERNA_CMD} {js_spec}"
53+
if force:
54+
lerna_cmd += " --yes"
55+
run(shlex.split(lerna_cmd), cwd=HERE, check=True)
56+
57+
path = HERE.joinpath("package.json")
58+
if path.exists():
59+
with path.open(mode="r") as f:
60+
data = json.load(f)
61+
62+
data["version"] = js_version
63+
64+
with path.open(mode="w") as f:
65+
json.dump(data, f, indent=2)
66+
67+
else:
68+
raise FileNotFoundError(f"Could not find package.json under dir {path!s}")
69+
70+
71+
if __name__ == "__main__":
72+
parser = argparse.ArgumentParser("bump_version", "Bump package version")
73+
parser.add_argument("--force", action="store_true")
74+
parser.add_argument("spec")
75+
76+
args = parser.parse_args()
77+
bump(args.force, args.spec)

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ignore=E123,E265,E261,E226,E241,E221,E251s
77
max-line-length=140
88

99
[metadata]
10-
license_file = LICENSE.md
10+
license_files = LICENSE.md
1111

1212
[manifix]
1313
known-excludes =

0 commit comments

Comments
 (0)