diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 82c9f8ee..5d08e2ac 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -4,6 +4,8 @@ on: branches: ["*"] pull_request: branches: ["*"] + release: + types: [published] schedule: - cron: "0 0 * * *" diff --git a/jupyter_releaser/changelog.py b/jupyter_releaser/changelog.py index d2bda04e..86751e6d 100644 --- a/jupyter_releaser/changelog.py +++ b/jupyter_releaser/changelog.py @@ -41,15 +41,7 @@ def format_pr_entry(target, number, auth=None): def get_version_entry( - branch, - repo, - version, - *, - since=None, - until=None, - auth=None, - resolve_backports=False, - remote="origin", + branch, repo, version, *, since=None, until=None, auth=None, resolve_backports=False ): """Get a changelog for the changes since the last tag on the given branch. @@ -69,8 +61,6 @@ def get_version_entry( The GitHub authorization token resolve_backports: bool, optional Whether to resolve backports to the original PR - remote: str, optional - The remote target (default is origin) Returns ------- @@ -80,17 +70,15 @@ def get_version_entry( if not since: tags = util.run( - f"git --no-pager tag --sort=-creatordate --merged {remote}/{branch}", - quiet=True, + f"git --no-pager tag --sort=-creatordate --merged {branch}", quiet=True ) if tags: since = tags.splitlines()[0] util.log(f"Getting changes to {repo} since {since} on branch {branch}...") - until = until or util.run( - f'git --no-pager log -n 1 {remote}/{branch} --pretty=format:"%H"' - ) + until = until or util.run(f'git --no-pager log -n 1 {branch} --pretty=format:"%H"') + until = until.replace("%", "") md = generate_activity_md( diff --git a/jupyter_releaser/lib.py b/jupyter_releaser/lib.py index 8532c914..6aaf0a10 100644 --- a/jupyter_releaser/lib.py +++ b/jupyter_releaser/lib.py @@ -365,7 +365,9 @@ def publish_assets(dist_dir, npm_token, npm_cmd, twine_cmd, dry_run): os.environ.setdefault("TWINE_USERNAME", "__token__") if len(glob(f"{dist_dir}/*.tgz")): - npm.handle_npm_config(npm_token, dist_dir) + npm.handle_npm_config(npm_token, os.getcwd()) + if npm_token: + util.run("npm whoami", cwd=os.getcwd()) found = False for path in sorted(glob(f"{dist_dir}/*.*")): diff --git a/jupyter_releaser/npm.py b/jupyter_releaser/npm.py index be937ca3..d01dca6f 100644 --- a/jupyter_releaser/npm.py +++ b/jupyter_releaser/npm.py @@ -134,6 +134,7 @@ def handle_npm_config(npm_token, dist_dir): text += f"\n{registry}:_authToken={npm_token}" if npmrc.exists(): text = npmrc.read_text(encoding="utf-8") + text + util.log(f"writing npm config to {npmrc}:\n{text}") npmrc.write_text(text, encoding="utf-8") diff --git a/jupyter_releaser/tests/test_cli.py b/jupyter_releaser/tests/test_cli.py index 7211db1f..0348d8f2 100644 --- a/jupyter_releaser/tests/test_cli.py +++ b/jupyter_releaser/tests/test_cli.py @@ -647,8 +647,6 @@ def wrapped(cmd, **kwargs): runner( [ "publish-assets", - "--npm-token", - "abc", "--npm-cmd", "npm publish --dry-run", "--dist-dir", diff --git a/jupyter_releaser/tests/test_functions.py b/jupyter_releaser/tests/test_functions.py index 4284b37e..71881a2b 100644 --- a/jupyter_releaser/tests/test_functions.py +++ b/jupyter_releaser/tests/test_functions.py @@ -1,12 +1,14 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json +import os import shutil from pathlib import Path import toml from jupyter_releaser import changelog +from jupyter_releaser import npm from jupyter_releaser import util from jupyter_releaser.tests import util as testutil from jupyter_releaser.util import run @@ -108,6 +110,12 @@ def test_create_release_commit_hybrid(py_package, build_mock): assert util.normalize_path("dist/foo-0.0.2a0.tar.gz") in shas +def test_handle_npm_config(npm_package): + npm.handle_npm_config("abc", os.getcwd()) + text = Path(".npmrc").read_text(encoding="utf-8") + assert "_authToken=abc" in text + + def test_bump_version(py_package): for spec in ["1.0.1", "1.0.1.dev1", "1.0.3a4"]: util.bump_version(spec)