# publish Publishes a library's build output to the npm registry, and skips a version the registry already has, so the same task can run again after a partial release. ```json { "publish": { "executor": "@hyperfrontend/workspace:publish", "dependsOn": ["build"] } } ``` | Option | What it does | | -------------- | ---------------------------------------------------------------------- | | `--dryRun` | Shows what would be published and uploads nothing | | `--registry` | The registry; defaults to the one npm is configured with | | `--tag` | The dist-tag; defaults to latest | | `--access` | The access of a scoped package; defaults to public | | `--otp` | A one-time password for two-factor publishing | | `--provenance` | Attaches the provenance statement npm signs with the CI identity token | The token comes from NPM_TOKEN in the environment. ```bash npx hf run my-utils:publish --dryRun ``` ## API Reference ### Functions #### publishExecutor ```typescript function publishExecutor(options: PublishExecutorOptions, context: ExecutorContext): Promise ``` Publish executor for the libraries of a workspace. Publishes a library's build output, wherever its `build` target writes it, to the npm registry with support for: - Dry-run mode to preview what would be published - Custom registry URL - NPM dist-tags - Scope access control - 2FA OTP support **Parameters** | Name | Type | Description | | --- | --- | --- | | `options` | `PublishExecutorOptions` | Options for the publish executor | | `context` | `ExecutorContext` | The workspace, the project and the target the task runs on | **Returns** `Promise`: Success status **Example: A `publish` target run after the build** ```json { "targets": { "publish": { "executor": "@hyperfrontend/workspace:publish", "dependsOn": ["build"], "options": { "access": "public", "tag": "latest", "provenance": true } } } } ``` `npx hf run lib-core:publish --dryRun` previews the npm command; a version the registry already has is skipped with success. ### Interfaces #### PublishExecutorOptions Options for the publish executor. **Properties** | Name | Type | Description | | --- | --- | --- | | `dryRun?` | `boolean` | Run in dry-run mode without actually publishing | | `registry?` | `string` | Custom npm registry URL | | `tag?` | `string` | NPM dist-tag to publish with | | `access?` | `"public" \| "restricted"` | Publish access level for scoped packages | | `otp?` | `string` | One-time password for npm 2FA | | `provenance?` | `boolean` | Attach a provenance statement signed with the CI identity token | --- Canonical page: https://www.hyperfrontend.dev/docs/libraries/workspace/executors/publish/ This file: https://www.hyperfrontend.dev/docs/libraries/workspace/executors/publish.md Documentation index: https://www.hyperfrontend.dev/llms.txt