# Publish

Publish artifacts to artifact registries. When sfp server is configured, artifacts are automatically published to sfp server. Use --npm to additionally publish to external npm registries.

* [`sfp publish`](#sfp-publish)

## `sfp publish`

Publish artifacts to artifact registries. When sfp server is configured, artifacts are automatically published to sfp server. Use --npm to additionally publish to external npm registries.

```
USAGE
  $ sfp publish -d <value> [--json] [--repository <value>] [-e <value>] [-t <value>] [--sfp-server-url
    <value>] [-p -v <value>] [-t <value>] [--gittag] [--gittaglimit <value>] [--gittagage <value>] [--pushgittag]
    [--scope <value>] [--npmtag <value> [--npm | -f <value>]] [--npmrcpath <value> ] [-g <value>...] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] [--npmauthtoken <value>] [--provider
    github|gitlab|npm ]

FLAGS
  -d, --artifactdir=<value>         (required) [default: artifacts] The directory containing artifacts to be published
  -e, --email=<value>               Email address for authenticated user. Ignored if --application-token is provided.
                                    Can be set via SFP_SERVER_USER env var.
  -f, --scriptpath=<value>          Path to script that authenticates and uploaded artifacts to the registry
  -g, --logsgroupsymbol=<value>...  Symbol used by CICD platform to group/collapse logs in the console. Provide an
                                    opening group, and an optional closing group symbol.
  -p, --publishpromotedonly         Only publish unlocked packages that have been promoted
  -t, --application-token=<value>   Application token for CI/CD authentication. Can be set via SFP_SERVER_TOKEN env var
                                    (CLI flags take precedence over env vars).
  -t, --tag=<value>                 Tag the publish with a label, useful for identification in metrics
  -v, --devhubalias=<value>         Username or alias of the Dev Hub org.
      --gittag                      Tag the current commit ID with an annotated tag containing the package name and
                                    version - does not push tag
      --gittagage=<value>           Specifies the number of days,for a tag to be retained,any tags older the provided
                                    number will be deleted
      --gittaglimit=<value>         Specifies the minimum number of  tags to be retained for a package
      --loglevel=<option>           [default: info] logging level for this command invocation
                                    <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>
      --npm                         Additionally publish artifacts to an external npm registry
      --npmauthtoken=<value>        [env: NPM_AUTH_TOKEN] NPM auth token for package registry. Defaults to GITHUB_TOKEN
                                    in GitHub Actions, CI_JOB_TOKEN in GitLab CI, or NPM_TOKEN
      --npmrcpath=<value>           Path to .npmrc file used for authentication to registry. If --sfp-server-url is
                                    provided and this flag is not set, npmrc will be fetched from the server instead. If
                                    left blank, defaults to home directory
      --npmtag=<value>              Add an optional distribution tag to NPM packages. If not provided, the 'latest' tag
                                    is set to the published version.
      --provider=<option>           Registry provider (github, gitlab, npm). Auto-detected from CI environment if not
                                    specified
                                    <options: github|gitlab|npm>
      --pushgittag                  Pushes the git tags created by this command to the repo, ensure you have access to
                                    the repo
      --repository=<value>          The repository identifier. E.g `owner/repo` for GitHub/GitLab or `org/project/repo`
                                    for Azure DevOps
      --scope=<value>               User or Organisation scope of the NPM package. Required for --npm when sfp server is
                                    not configured
      --sfp-server-url=<value>      URL of the SFP server. Can be set via SFP_SERVER_URL env var or config: sfp
                                    config:set server-url

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Publish artifacts to artifact registries. When sfp server is configured, artifacts are automatically published to sfp
  server. Use --npm to additionally publish to external npm registries.

ALIASES
  $ sfp artifacts publish

EXAMPLES
  $ sfp publish -d artifacts

  $ sfp publish --npm --scope myorg

  $ sfp publish --npm --scope myorg --sfp-server-url https://sfp.example.com
```

*See code:* [*src/commands/publish.ts*](https://source.flxbl.io/flxbl/sfp-pro)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp/sfp-community/cli-reference-v51-release-v3/core/publish.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
