Skip to content

Commit 2d1ca36

Browse files
authored
Set up releaser (#710)
* Set up releaser * Fix CI * Add version to root package * Debug * Some fixes * JupyterLab is required to build the lab extension * Ignore duplication warning for wheel * Fix package-lock * Try using releaser run * Apparently --yes cli option matters * Fix bump script * Fix package-lock
1 parent 5dcaf5c commit 2d1ca36

13 files changed

+347
-20
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 }}

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
<!-- <START NEW CHANGELOG ENTRY> -->
4+
5+
<!-- <END NEW CHANGELOG ENTRY> -->

RELEASE.md

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Making a new release of nbdime
2+
3+
The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).
4+
5+
## Manual release
6+
7+
### Python package
8+
9+
This extension can be distributed as Python packages. All of the Python
10+
packaging instructions are in the `pyproject.toml` file to wrap your extension in a
11+
Python package. Before generating a package, you first need to install some tools:
12+
13+
```bash
14+
pip install build twine hatch
15+
```
16+
17+
Bump the version using the custom script:
18+
19+
```bash
20+
python scripts/bump_version.py <new-version>
21+
```
22+
23+
> _\<new-version\>_ can be a segment like `major`, `minor`, `patch`, `alpha`,...
24+
25+
Make sure to clean up all the development files before building the package:
26+
27+
```bash
28+
jlpm clean:all
29+
```
30+
31+
You could also clean up the local git repository:
32+
33+
```bash
34+
git clean -dfX
35+
```
36+
37+
To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:
38+
39+
```bash
40+
python -m build
41+
```
42+
43+
> `python setup.py sdist bdist_wheel` is deprecated and will not work for this package.
44+
45+
Then to upload the package to PyPI, do:
46+
47+
```bash
48+
twine upload dist/*
49+
```
50+
51+
### NPM package
52+
53+
To publish the frontend part of the extension as a NPM package, do:
54+
55+
```bash
56+
npm login
57+
npm publish --access public
58+
```
59+
60+
## Automated releases with the Jupyter Releaser
61+
62+
The extension repository should already be compatible with the Jupyter Releaser.
63+
64+
Check out the [workflow documentation](https://jupyter-releaser.readthedocs.io/en/latest/get_started/making_release_from_repo.html) for more information.
65+
66+
Here is a summary of the steps to cut a new release:
67+
68+
- Add tokens to the [Github Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) in the repository:
69+
- `ADMIN_GITHUB_TOKEN` (with "public_repo" and "repo:status" permissions); see the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
70+
- `NPM_TOKEN` (with "automation" permission); see the [documentation](https://docs.npmjs.com/creating-and-viewing-access-tokens)
71+
- Set up PyPI
72+
73+
<details><summary>Using PyPI trusted publisher (modern way)</summary>
74+
75+
- Set up your PyPI project by [adding a trusted publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/)
76+
- The _workflow name_ is `publish-release.yml` and the _environment_ should be left blank.
77+
- Ensure the publish release job as `permissions`: `id-token : write` (see the [documentation](https://docs.pypi.org/trusted-publishers/using-a-publisher/))
78+
79+
</details>
80+
81+
<details><summary>Using PyPI token (legacy way)</summary>
82+
83+
- If the repo generates PyPI release(s), create a scoped PyPI [token](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#saving-credentials-on-github). We recommend using a scoped token for security reasons.
84+
85+
- You can store the token as `PYPI_TOKEN` in your fork's `Secrets`.
86+
87+
- Advanced usage: if you are releasing multiple repos, you can create a secret named `PYPI_TOKEN_MAP` instead of `PYPI_TOKEN` that is formatted as follows:
88+
89+
```text
90+
owner1/repo1,token1
91+
owner2/repo2,token2
92+
```
93+
94+
If you have multiple Python packages in the same repository, you can point to them as follows:
95+
96+
```text
97+
owner1/repo1/path/to/package1,token1
98+
owner1/repo1/path/to/package2,token2
99+
```
100+
101+
</details>
102+
103+
- Go to the Actions panel
104+
- Run the "Step 1: Prep Release" workflow
105+
- Check the draft changelog
106+
- Run the "Step 2: Publish Release" workflow
107+
108+
## Publishing to `conda-forge`
109+
110+
If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html
111+
112+
Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically.

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

package-lock.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "nbdime-top-repo",
3+
"version": "4.0.0-alpha.0",
34
"private": true,
45
"workspaces": [
56
"packages/*"

packages/webapp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "nbdime-webapp",
3+
"version": "4.0.0-alpha.0",
34
"private": true,
45
"license": "BSD-3-Clause",
56
"main": "static/nbdime.js",

pyproject.toml

+15
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ docs = [
8989
"sphinx_rtd_theme",
9090
]
9191

92+
[tool.check-wheel-contents]
93+
ignore = ["W002"]
94+
9295
[tool.hatch.version]
9396
path = "nbdime/_version.py"
9497

@@ -129,6 +132,18 @@ skip-if-exists = [
129132
source_dir = "packages"
130133
build_dir = "nbdime/labextension"
131134

135+
[tool.jupyter-releaser.options]
136+
version-cmd = "python scripts/bump_version.py --force"
137+
138+
[tool.jupyter-releaser.hooks]
139+
before-bump-version = [
140+
"npm install"
141+
]
142+
before-build-npm = [
143+
"python -m pip install 'jupyterlab>=4.0.0,<5'",
144+
"npm run build"
145+
]
146+
132147
[tool.pytest.ini_options]
133148
testpaths = "nbdime/tests"
134149
norecursedirs = "node_modules"

0 commit comments

Comments
 (0)