Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prep-self-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"

- name: Install Dependencies
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-self-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Install Dependencies
shell: bash
run: |
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- name: Run Linters
run: |
hatch run typing:test
Expand All @@ -32,6 +34,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
with:
ignore_links: https://blog.jupyter.org/.*
Expand All @@ -46,6 +50,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"

- name: Run the tests with coverage on Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand All @@ -72,6 +78,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RH_REPOSITORY: jupyter-server/jupyter_releaser
Expand Down Expand Up @@ -103,6 +111,7 @@ jobs:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
dependency_type: minimum
node_version: "24.x"
- name: Run the unit tests
run: |
hatch run test:nowarn || hatch run test:nowarn --lf
Expand All @@ -117,6 +126,7 @@ jobs:
with:
dependency_type: pre
python_version: "3.12"
node_version: "24.x"
- name: Run the tests
run: |
hatch run test:nowarn || hatch run test:nowarn --lf
Expand All @@ -127,13 +137,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"
- run: hatch run docs:build

check_local_actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
node_version: "24.x"

- name: prep-release
uses: ./.github/actions/prep-release
Expand Down
11 changes: 10 additions & 1 deletion jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,16 @@ def publish_assets(
twine_cmd = "pipx run twine upload --repository-url=http://0.0.0.0:8081"
os.environ["TWINE_USERNAME"] = "foo"
twine_token = twine_token or "bar"
npm_cmd = "npm publish --dry-run"
# Preserve --tag flag if it was added for prereleases
if " --tag " in npm_cmd:
# Extract the tag and add --dry-run while preserving it
tag_match = re.search(r"--tag\s+(\S+)", npm_cmd)
if tag_match:
npm_cmd = f"npm publish --dry-run --tag {tag_match.group(1)}"
else:
npm_cmd = "npm publish --dry-run"
else:
npm_cmd = "npm publish --dry-run"
else:
os.environ.setdefault("TWINE_USERNAME", "__token__")

Expand Down
12 changes: 7 additions & 5 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def _run_win(cmd, **kwargs):
"""Run a command as a subprocess and get the output as a string"""
quiet = kwargs.pop("quiet", False)

if not quiet:
kwargs.setdefault("stderr", PIPE)
# Always capture stderr so we can decode/log it on error
kwargs.setdefault("stderr", PIPE)

kwargs.setdefault("shell", True)

Expand All @@ -117,11 +117,13 @@ def _run_win(cmd, **kwargs):
log(output)
return output
except CalledProcessError as e:
e.output = e.output.decode("utf-8")
if quiet:
if e.output is not None:
e.output = e.output.decode("utf-8")
if quiet and e.stderr is not None:
e.stderr = e.stderr.decode("utf-8")
log("stderr:\n", e.stderr.strip(), "\n\n")
log("stdout:\n", e.output.strip(), "\n\n")
if e.output:
log("stdout:\n", e.output.strip(), "\n\n")
if check:
raise e

Expand Down
31 changes: 31 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,37 @@ def npm_dist(workspace_package, runner, mocker, git_prep):
return workspace_package


@pytest.fixture()
def npm_dist_prerelease(workspace_package, runner, mocker, git_prep):
"""Fixture for npm packages with a prerelease version (e.g., 1.0.0-alpha.0).

To test npm 11+ behavior which requires --tag for prereleases.
"""
prerelease_version = "1.0.0-alpha.0"

changelog_entry = testutil.mock_changelog_entry(
workspace_package, runner, mocker, version_spec=prerelease_version
)

# Manually update workspace package versions
checkout_dir = Path(util.CHECKOUT_NAME)
for pkg_dir in (checkout_dir / "packages").iterdir():
if pkg_dir.is_dir():
pkg_json = pkg_dir / "package.json"
if pkg_json.exists():
data = json.loads(pkg_json.read_text(encoding="utf-8"))
data["version"] = prerelease_version
pkg_json.write_text(json.dumps(data), encoding="utf-8")

# Create the dist files
runner(["build-npm"])

# Finalize the release
runner(["tag-release"])

return workspace_package


@pytest.fixture()
def runner():
cli_runner = CliRunner()
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,26 @@ def wrapped(cmd, **kwargs):
assert called == 3, called


def test_publish_assets_npm_prerelease_dry_run(npm_dist_prerelease, runner, mock_github):
"""Test that prereleases work with --dry-run flag (npm 11+ compatibility)

npm 11+ requires --tag when publishing prerelease versions.
This test ensures the --tag flag is preserved in dry-run mode.
If the --tag is missing, npm 11 will fail with:
"You must specify a tag using --tag when publishing a prerelease version."
"""
# Create the release.
dist_dir = npm_dist_prerelease / util.CHECKOUT_NAME / "dist"
release = create_draft_release("bar", glob(f"{dist_dir!s}/*.*"))

os.environ["RH_RELEASE_URL"] = release.html_url

# Use --dry-run flag to trigger the dry_run code path
# This will actually call npm 11 publish --dry-run
# If --tag is missing, npm 11 will reject it and the test will fail
runner(["publish-assets", "--dist-dir", dist_dir, "--dry-run"])


def test_publish_release(npm_dist, runner, mocker, mock_github, draft_release):
os.environ["RH_RELEASE_URL"] = draft_release
runner(["publish-release"])
Expand Down