Skip to content

Add npm publishing workflow for Aspire CLI packages#17297

Draft
adamint wants to merge 4 commits into
microsoft:davidfowl/npm-cli-packagefrom
adamint:dev/adamint/npm-cli-package-followups
Draft

Add npm publishing workflow for Aspire CLI packages#17297
adamint wants to merge 4 commits into
microsoft:davidfowl/npm-cli-packagefrom
adamint:dev/adamint/npm-cli-package-followups

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented May 20, 2026

Description

This adds the missing npm publish path for the Aspire CLI npm package work. The branch can now take the microsoft-aspire-cli*.tgz tarballs already produced by the native archive build and publish them through a manual, dry-run-by-default GitHub Actions workflow.

The workflow is designed for Microsoft-managed publishing of the @microsoft/aspire-cli packages:

  • Uses npm Trusted Publisher/OIDC provenance by default, with a temporary secrets.NPM_TOKEN fallback until Trusted Publisher setup is complete.
  • Publishes RID-specific packages before the meta package and waits for npm propagation before publishing the meta package.
  • Supports latest, next, daily, and pr-<N> dist-tags, plus only_rid and skip_meta recovery knobs.
  • Validates exact versioned tarball names to avoid publishing artifacts from the wrong build.
  • Documents the external prerequisites and manual publish command in docs/specs/npm-cli-package.md.

Example dry run:

gh workflow run publish-npm.yml \
  --ref main \
  --field release_version="9.2.0" \
  --field run_id="12345678" \
  --field dist_tag="latest" \
  --field dry_run="true"

Security considerations

This change adds release infrastructure that can publish packages to npm. Real publishes are restricted to repository users with admin or maintain permission, use GitHub OIDC/npm provenance, and include a temporary NPM_TOKEN fallback that should be removed after Trusted Publisher configuration is complete. Security review is recommended for the publishing permissions, Trusted Publisher binding, and temporary token fallback before enabling real publishes.

Fixes #17045

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Validation:

  • python3 YAML parse of .github/workflows/publish-npm.yml
  • dotnet test --project tests/Infrastructure.Tests/Infrastructure.Tests.csproj --no-launch-profile -- --filter-class "*.StageNativeCliToolPackagesTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" (11 passed)

adamint and others added 4 commits May 19, 2026 17:58
- Create .github/workflows/publish-npm.yml for manual npm package publishing
- Support workflow_dispatch with inputs for version, run_id, dist_tag, pr_number, only_rid, skip_meta, and dry_run
- Enable npm provenance via id-token: write permission for Trusted Publisher OIDC
- Require admin/maintain permission for non-dry-run publishes
- Download artifacts from specified GitHub Actions run_id
- Publish RID packages before meta package with fail-fast: false matrix
- Wait for RID packages to propagate on npm before publishing meta package
- Support fallback to NPM_TOKEN secret until Trusted Publisher OIDC is configured
- Include recovery options via only_rid and skip_meta inputs
- Generate workflow summary with job status and next steps
- Update docs/specs/npm-cli-package.md with publishing section and prerequisites

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tion

The MISSING_PACKAGES counter was incremented inside a pipeline subshell
and never propagated to the parent shell, causing the verification check
to always see 0 and never fail on missing tarballs.

Changed from pipeline (echo | jq | while) to process substitution
(while < <(echo | jq)) so the while loop runs in the main shell and
variable updates are visible to the later check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When dry_run=true, wait-for-packages is skipped, which previously
allowed publish-meta-package to start without waiting for
publish-rid-packages to complete. This violated the spec requirement
that RID packages must be published/validated before the meta package.

Changes:
- Add publish-rid-packages to publish-meta-package job needs
- Update if condition to require publish-rid-packages.result == 'success'
- Preserve existing behavior: wait-for-packages can be skipped (dry run)
  but only after RID packages complete successfully

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eout

Address code review findings:

1. Exact version matching for tarballs:
   - Replace broad patterns (microsoft-aspire-cli-$RID-*.tgz) with exact
     version patterns (microsoft-aspire-cli-$RID-$VERSION.tgz)
   - Apply to download verification, publish-rid-packages, and
     publish-meta-package steps
   - Improve error messages to show exact expected filename when missing

2. Configurable propagation timeout:
   - Add propagation_timeout_seconds workflow input (default 900s = 15min)
   - Validate input is positive integer in validate job
   - Compute MAX_ATTEMPTS from timeout/sleep interval, rounding up
   - Include timeout in workflow summary and parameter output
   - Preserve bounded polling and dry-run skip behavior

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint adamint marked this pull request as draft May 20, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant