feat(apps): add publish option and DD_APPS_PUBLISH env var by setnilson · Pull Request #416 · DataDog/build-plugins · GitHub
Skip to content

feat(apps): add publish option and DD_APPS_PUBLISH env var#416

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
masterfrom
sarah.nilson/apps-upload-without-publish
Jul 1, 2026
Merged

feat(apps): add publish option and DD_APPS_PUBLISH env var#416
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
masterfrom
sarah.nilson/apps-upload-without-publish

Conversation

@setnilson

@setnilson setnilson commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

High-code apps had no way to upload a new version without immediately publishing it live. Every upload triggered a release/live call, making it impossible to stage a version for review before promotion.

Changes

Adds a publish option to the apps plugin that controls whether release/live is called after a successful upload:

  • apps.publish: false in vite.config.ts skips the publish step
  • DD_APPS_PUBLISH=false / DATADOG_APPS_PUBLISH=false env var does the same without touching config
  • Explicit config takes precedence over the env var
  • Defaults to true — existing behavior is unchanged

The companion web-ui PR (DataDog/web-ui#319459) adds an upload-no-publish script to the scaffolder so users don't need to know the env var:

"upload": "DD_APPS_UPLOAD_ASSETS=1 vite build",
"upload-no-publish": "DD_APPS_UPLOAD_ASSETS=1 DD_APPS_PUBLISH=false vite build"

Files changed:

  • packages/core/src/helpers/env.ts — registers APPS_PUBLISH env var
  • packages/plugins/apps/src/types.ts — adds publish to AppsOptions and AppsOptionsWithDefaults
  • packages/plugins/apps/src/validate.ts — resolves publish from config or env var
  • packages/plugins/apps/src/upload.ts — gates the release/live PUT call on context.publish
  • packages/plugins/apps/src/vite/handle-upload.ts — passes options.publish through
  • packages/plugins/apps/README.md — documents apps.publish and the recommended script pattern
  • Tests updated throughout (250 passing)

QA Instructions

A test app is in DataDog/experimental using the published @datadog/vite-plugin. Each build bakes in a timestamp and unique badge color so you can tell at a glance whether the live version changed.

git clone git@github.com:DataDog/experimental.git
cd experimental/user/setnilson/deploy-test-app
npm install

Test 1 — upload and publish in one shot (existing behavior, should still work):

dd-auth --actions-api --domain app.datadoghq.com -- npm run upload

Open the app in App Builder. Badge color and timestamp should change on reload.

Test 2 — upload a draft without publishing:

dd-auth --actions-api --domain app.datadoghq.com -- npm run upload-no-publish

The live badge should not change after reload — the draft is saved but not live.

Test 3 — publish the draft:

Go to App Builder, open the app, and publish the draft version from the version history. Badge should now update.

Blast Radius

Only affects apps using @datadog/vite-plugin with apps.enable: true. Defaults to true so no existing upload flow changes. The new env var is opt-in.

@setnilson setnilson marked this pull request as ready for review June 17, 2026 17:32
@setnilson setnilson requested review from a team and yoannmoinet as code owners June 17, 2026 17:32
@setnilson setnilson requested a review from sdkennedy2 June 17, 2026 17:39
setnilson and others added 3 commits June 29, 2026 10:56
Add a `publish` option to the apps plugin that controls whether the
`release/live` API call fires after a successful upload. Defaults to
`true` (existing behavior unchanged). Set `publish: false` in
vite.config.ts or pass `DD_APPS_PUBLISH=false` to upload a draft
without making it live.

Recommended package.json pattern:
  "upload-no-publish": "DD_APPS_UPLOAD_ASSETS=1 DD_APPS_PUBLISH=false vite build"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a `datadog-apps` binary to `@datadog/vite-plugin` with two commands:

  deploy [--no-publish]     - build, upload, and publish (default).
                              --no-publish uploads a draft only.
  publish [--version <id>]  - publish an already-uploaded version without
                              rebuilding. Defaults to the most recent version
                              recorded in .datadog-app-version.json.

After each successful deploy, the version_id and app identifier are written
to .datadog-app-version.json so `publish` works without arguments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The upload tests were writing .datadog-app-version.json to disk as a
side effect. Mock writeVersionCache in the test module and add the
cache file to .gitignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@setnilson setnilson force-pushed the sarah.nilson/apps-upload-without-publish branch from 5e2ac30 to fd4d4a1 Compare June 29, 2026 14:57
@setnilson setnilson requested a review from a team as a code owner June 29, 2026 14:57
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 29, 2026

Copy link
Copy Markdown

setnilson and others added 3 commits June 29, 2026 11:34
Remove shebang from cli.ts source (rollup adds it as a banner to the
compiled output). Fix header ordering flagged by 'yarn cli integrity'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move the datadog-apps CLI binary from @datadog/vite-plugin into a new
standalone package @datadog/apps-cli. This keeps @datadog/vite-plugin
focused on bundler integration.

@datadog/vite-plugin no longer ships a bin entry or CLI bundle.
@datadog/apps-cli packages the same CLI with its own package.json,
versioning, and rollup config.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CLI work (datadog-apps binary, @datadog/apps-cli, version-cache) will
ship in a stacked PR once the CLI home is decided. This PR now only
covers the publish option and DD_APPS_PUBLISH env var.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@setnilson setnilson changed the title feat(apps): add publish option to upload without auto-publishing feat(apps): add publish option and DD_APPS_PUBLISH env var Jun 30, 2026
setnilson and others added 3 commits June 30, 2026 11:41
…om types

No need to thread publish through AppsOptions → validate → UploadContext.
Just read getDDEnvValue('APPS_PUBLISH') directly in uploadArchive where
the decision is made. Simpler and keeps the types clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both were left over from local testing — no functional changes intended.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread packages/plugins/apps/src/upload.ts Outdated
}

if (response.version_id) {
const shouldPublish = getDDEnvValue('APPS_PUBLISH') !== 'false';

@sdkennedy2 sdkennedy2 Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice our existing APPS_UPLOAD_ASSETS docs mention we set APPS_UPLOAD_ASSETS=1 versus here we are using a boolean value. Perhaps we create a helper function for normalizing this so that a customer could set 0/1 or false/true. Then we use the helper when evaluating both env variables.

…ling

Both APPS_UPLOAD_ASSETS and APPS_PUBLISH now accept 0, 1, false, true,
yes, no, on, off (case-insensitive) instead of relying on JS truthiness
or an exact 'false' string check.

Fixes: DD_APPS_UPLOAD_ASSETS=false would incorrectly enable upload (any
non-empty string was truthy). DD_APPS_PUBLISH=0 would not disable publish
(only the literal 'false' was checked).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@setnilson

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 1, 2026

Copy link
Copy Markdown

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit bc092fe into master Jul 1, 2026
5 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the sarah.nilson/apps-upload-without-publish branch July 1, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants