Make the repository compatible with Jupyter Releaser
jtpio opened this issue · 6 comments
Problem
Extension authors creating a new extension from this cookiecutter will very likely want to release it at some point.
For now there is no real instructions for releasing the extension in the cookicutter itself, just a couple of notes in the extension tutorial: https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html#publishing-your-extension
Ideally, the generated extension would automatically be compatible with the Jupyter Releaser so it can be published to both PyPI and npm: https://github.com/jupyter-server/jupyter_releaser
Proposed Solution
- follow the checklist https://github.com/jupyter-server/jupyter_releaser#Checklist-for-Adoption (adding the missing files and configuration)
- document the release process in the cookiecutter readme
Additional context
This topic was also discussed in #101
Testing on a simple (soon to be archived) repo: https://github.com/jtpio/jupyterlab-python-file, logging here some findings.
It looks like the "Draft Release Action" current builds npm before Python:
And the cookiecutter assumes using jlpm
which requires installing jupyterlab
as a build dependency, which makes the workflow fail:
Adding the following hook to the package.json
builds the package:
"jupyter-releaser": {
"hooks": {
"before-build-npm": [
"python -m pip install jupyterlab~=3.0",
"jlpm"
]
}
},
But then stops a bit later when trying to extract the package:
Probably because the result of npm pack
contains more than just the path to the tarball.
Probably because the result of
npm pack
contains more than just the path to the tarball.
Checking the last line of the command output seems to do the trick for now:
diff --git a/jupyter_releaser/npm.py b/jupyter_releaser/npm.py
index d1c6aa6..731e087 100644
--- a/jupyter_releaser/npm.py
+++ b/jupyter_releaser/npm.py
@@ -24,7 +24,7 @@ def build_dist(package, dist_dir):
if osp.isdir(package):
basedir = package
- tarball = osp.join(package, util.run("npm pack", cwd=package))
+ tarball = osp.join(package, util.run("npm pack", cwd=package).split('\n')[-1])
else:
basedir = osp.dirname(package)
tarball = package
Next the releaser tries to import the package, but since that test extension is not importable it fails a little bit after:
Also the cookiecutter now defaults to underscores for the package name which it means it shouldn't be an issue with a fresh new extension.
Looks like everything went well after:
- adding the hook as mentioned in #162 (comment)
- using the
npm pack
fix mentioned in #162 (comment) - explicitly creating
.npmrc
in the home directory with (probably something to fix injupyter_releaser
directly):
.github/actions/publish-release/action.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/actions/publish-release/action.yml b/.github/actions/publish-release/action.yml
index 15b4844..517db7e 100644
--- a/.github/actions/publish-release/action.yml
+++ b/.github/actions/publish-release/action.yml
@@ -31,6 +31,8 @@ runs:
export RH_DRY_RUN=${{ inputs.dry_run }}
export release_url=${{ inputs.release_url }}
export RH_NPM_COMMAND="npm publish --access public"
+
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
# Install Jupyter Releaser from git
pip install -q git+https://github.com/jupyter-server/jupyter_releaser.git@v1
explicitly creating
.npmrc
in the home directory with (probably something to fix injupyter_releaser
directly):
This could probably handled here: https://github.com/jupyter-server/jupyter_releaser/blob/cba7bf7981c41415eda5ae4d2d3026908f003211/jupyter_releaser/npm.py#L130-L141