CI/CD
A CI job can install LPM.dev Registry packages, publish a package, or pull an encrypted environment. Each of these operations uses a different credential.
| Operation | Authentication | Scope |
|---|---|---|
| Install private, Pool, or Marketplace packages | LPM_TOKEN | Read access of the token owner or organization |
| Publish with a static token | LPM_TOKEN | Publish access of that token |
| Publish with a Trusted Publisher | GitHub Actions or GitLab CI OIDC | One configured package |
| Pull an encrypted environment | Env OIDC policy | The environments that the policy of one project allows |
If an organization has an IP allowlist, LPM.dev Registry accepts installs of its private packages and all of its publishes only from allowed addresses. Make sure that the CI runner uses an allowed address.
Install LPM CLI before you use its package, publish, or env commands:
npm install -g @lpm-registry/cli
For reproducible workflows, pin the package to a version that you reviewed. The LPM CLI CI/CD guide explains installation choices, lockfile behavior, caching, and security gates.
Install packages with a read token
Create a read token in your personal token settings or in the token settings of the organization. Store it as LPM_TOKEN in the encrypted secret store of the CI provider.
A token expires after 7, 30, 60, or 90 days. Replace the secret before the token expires.
LPM CLI reads the token from LPM_TOKEN:
name: Build
on: push
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @lpm-registry/cli
- name: Install from the lockfile
run: lpm ci
env:
LPM_TOKEN: ${{ secrets.LPM_TOKEN }}
- run: npm test
Commit lpm.lock. Do not commit .lpm/. Do not cache node_modules.
If later runs need the same package data, cache the LPM CLI store.
npm, pnpm, or Yarn 1
An npm-compatible client reads the registry and the token from .npmrc. You can create this file in the job, or you can commit a file that contains no token.
To create the file in the job, run lpm setup ci npmrc before the install:
- name: Configure LPM.dev Registry
run: lpm setup ci npmrc
env:
LPM_TOKEN: ${{ secrets.LPM_TOKEN }}
- run: npm ci
The command takes the token from --token, from LPM_TOKEN, or from the stored LPM CLI session, in that order. It writes the token itself into .npmrc:
//lpm.dev/api/registry/:_authToken=lpm_...
@lpm.dev:registry=https://lpm.dev/api/registry/
The install step does not need LPM_TOKEN, because .npmrc contains the token. Do not upload .npmrc as an artifact. Do not put it in a cache.
The command stops if Git tracks .npmrc. It adds .npmrc to .git/info/exclude, so no tracked file changes.
In GitHub Actions or GitLab CI, lpm setup ci npmrc --oidc needs no LPM_TOKEN secret. It exchanges the job's OIDC token for a 30-minute read token. The read token acts for the LPM account that is connected to the GitHub or GitLab account that started the job. The job needs the same OIDC setup as a GitHub Actions or GitLab CI publish job.
To commit the file instead, write a .npmrc that reads the token from the environment:
@lpm.dev:registry=https://lpm.dev/api/registry/
//lpm.dev/api/registry/:_authToken=${LPM_TOKEN}
npm, pnpm, Yarn 1, and Bun replace ${LPM_TOKEN} with the value of the environment variable. Give the secret to the install step:
- run: npm ci
env:
LPM_TOKEN: ${{ secrets.LPM_TOKEN }}
Use one of the two options in a project. If Git tracks .npmrc, lpm setup ci npmrc does not work.
GitLab CI, Bitbucket Pipelines, and other providers use LPM_TOKEN in the same way. Mark the variable as protected. Make it available only to trusted branches or deployment environments.
Publish with a Trusted Publisher
A Trusted Publisher lets a GitHub Actions or GitLab CI job publish one existing package without a stored publish token. For GitLab, the job must run on GitLab.com.
Configure the package
The package owner, or an owner or admin of the organization that owns the package, can add a Trusted Publisher.
- Publish the package once with a signed-in LPM CLI session or a publish token.
- Open the package in the LPM.dev Registry dashboard.
- Open "Trusted publishers".
- Choose GitHub Actions or GitLab CI.
- Enter the repository owner and the repository name. For GitLab, enter the project path with its subgroups.
- Enter the workflow filename or the CI config filename.
- Choose the allowed ref. Use
refs/tags/v*for release tags that start withv. - If the workflow uses an environment, enter it.
- Save the configuration.
When you save, LPM.dev Registry looks up the immutable numeric repository ID or project ID and stores it. If the lookup fails, select "Enter repository ID manually" or "Enter project ID manually", and enter the ID.
To get the ID of a GitHub repository, run this command:
gh api repos/OWNER/REPOSITORY --jq .id
GitLab shows the project ID on the project overview page. These numeric IDs do not change when a repository name changes.
At each exchange, the numeric ID, the workflow filename, and the allowed ref must match the claims in the job's identity token. If the configuration has an environment, the job's environment must also match.
An exact branch or tag ref allows one ref. A tag pattern allows each tag that starts with the text before the *.
A pattern can have one *, at the end of a tag ref, such as refs/tags/v*. LPM.dev Registry rejects branch patterns and a * at any other position.
LPM.dev Registry compares the tag prefix as text. It does not read the pattern as a regular expression.
A configuration without an immutable ID and an allowed ref cannot publish. Select "Replace" on each such configuration and enter both values.
LPM.dev Registry issues tokens only for trusted triggers. For GitHub Actions, the event must be push, release, workflow_dispatch, schedule, or repository_dispatch. For GitLab CI, the pipeline source must be push, web, schedule, api, or trigger. Pull request and merge request jobs cannot get a token.
GitHub Actions
name: Publish
on:
push:
tags:
- "v*"
permissions:
id-token: write
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @lpm-registry/cli
- run: npm ci
- run: npm test
- run: lpm publish -y
With id-token: write, the job can request an identity token from GitHub. LPM CLI requests a token with the audience https://lpm.dev. Then it exchanges that token for a 15-minute publish token for the configured package.
Set the allowed ref to refs/tags/v*. A tag such as v1.2.3 then starts the workflow and matches the publisher.
If npm ci also installs private LPM.dev Registry packages, give a read token in LPM_TOKEN to that step only. The lpm publish step needs no LPM_TOKEN.
GitLab CI
publish:
stage: publish
image: node:22
id_tokens:
LPM_OIDC_TOKEN:
aud: https://lpm.dev
script:
- npm install -g @lpm-registry/cli
- npm ci
- npm test
- lpm publish -y
rules:
- if: '$CI_COMMIT_TAG =~ /^v/'
LPM CLI reads the GitLab identity token from LPM_OIDC_TOKEN. For this example, set the allowed ref to refs/tags/v*.
The Trusted Publisher must name the CI config file of the job, such as .gitlab-ci.yml.
GitLab creates LPM_OIDC_TOKEN when the job starts. The token expires at the timeout of the job. LPM.dev Registry accepts the token until it expires, for at most 6 hours. If lpm publish runs later than that, move the steps before it to an earlier job.
Review trusted publishes
The "Trusted publishers" page of the package lists recent OIDC publishes. Each row shows the version, the repository, the commit, and the workflow. The security history of the package also shows whether each release used OIDC or a static token.
Publish with a static token
Bitbucket Pipelines and other providers cannot use a Trusted Publisher. For these providers, store a publish token as LPM_TOKEN. Then run:
lpm publish -y
When you create the token, select the package in "Restrict to package". The token then works only for that package. Mark the CI variable as protected. If the token is exposed, rotate or revoke it.
If a GitHub Actions job has id-token: write, or a GitLab CI job sets LPM_OIDC_TOKEN, lpm publish uses the Trusted Publisher exchange. If the exchange fails, the publish stops. LPM CLI does not use LPM_TOKEN instead.
Environment OIDC is separate
lpm env pull --oidc uses an env OIDC policy and a project key that LPM.dev Registry stores encrypted. It gives no access to install or publish packages:
lpm env pull --oidc --env=production --output=.env
OIDC for CI explains how to set up this workflow. Platform integrations explains environment synchronization with deployment platforms.
Sigstore provenance is a separate LPM CLI feature. The LPM CLI publish reference explains --provenance, quality gates, dry runs, and publishing to more than one registry.
See also
- Authentication explains LPM CLI sessions and read tokens.
- Deployment platforms explains package access during builds on hosted platforms and in Docker.
- The LPM CLI setup reference lists the
lpm setupcommands and the files that they write. - The LPM CLI CI/CD guide explains lockfiles, caches, gates, and command flags.