Skip to content

feat(cli): add publish-assets command for asset publishing without deployment#1020

Merged
mrgrain merged 63 commits intoaws:mainfrom
go-to-k:publish
Apr 1, 2026
Merged

feat(cli): add publish-assets command for asset publishing without deployment#1020
mrgrain merged 63 commits intoaws:mainfrom
go-to-k:publish

Conversation

@go-to-k
Copy link
Copy Markdown
Contributor

@go-to-k go-to-k commented Jan 11, 2026

cdk publish-assets

Publishes assets for the specified stack(s) without performing a deployment.

Important

cdk publish-assets is under development and therefore must be opted in via the --unstable flag: cdk publish-assets --unstable=publish-assets. --unstable indicates that the scope and API of feature might still change. Otherwise the feature is generally production ready and fully supported.

Publishes assets (such as Docker images and file assets) for the specified stack(s) to their respective destinations (ECR repositories, S3 buckets) without performing a deployment.

This is useful in CI/CD pipelines where you want to separate the asset build/publish phase from the deployment phase.

$ # Publish assets for a single stack
$ cdk publish-assets MyStack --unstable=publish-assets

$ # Publish assets for all stacks
$ cdk publish-assets --all --unstable=publish-assets

$ # Force re-publish even if assets already exist
$ cdk publish-assets MyStack --unstable=publish-assets --force

Currently, cdk deploy combines asset publishing and stack deployment into a single operation. This makes it difficult to structure CI/CD pipelines where assets should be built and published once, then reused across multiple deployment stages (e.g. dev → staging → production). The solution today is to use the standalone cdk-assets CLI directly, which requires an additional dependency and likely not easily discoverable.

This PR adds cdk publish-assets as a first-class CLI command, making the same functionality available without extra dependencies and with the familiar CDK CLI experience (stack selectors, --exclusively, --all, --concurrency).

On the implementation side, the inline buildAsset and publishAsset functions in the deploy path have been extracted into reusable createBuildAssetFunction and createPublishAssetFunction methods on the Toolkit class, so both deploy and publish-assets share the same asset handling logic.

Fixes #982


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team January 11, 2026 17:42
@go-to-k go-to-k changed the title feat(cli): support publish command for asset publishing feat(cli): add publish command for asset publishing Jan 11, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 11, 2026

Codecov Report

❌ Patch coverage is 95.45455% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.19%. Comparing base (87b3f6c) to head (999a579).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
packages/aws-cdk/lib/cli/cli.ts 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1020      +/-   ##
==========================================
+ Coverage   88.17%   88.19%   +0.01%     
==========================================
  Files          73       73              
  Lines       10345    10386      +41     
  Branches     1403     1410       +7     
==========================================
+ Hits         9122     9160      +38     
- Misses       1196     1199       +3     
  Partials       27       27              
Flag Coverage Δ
suite.unit 88.19% <95.45%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@go-to-k
Copy link
Copy Markdown
Contributor Author

go-to-k commented Apr 1, 2026

@mrgrain Applied your comments!

@go-to-k go-to-k requested a review from mrgrain April 1, 2026 05:10
@mrgrain mrgrain temporarily deployed to integ-approval April 1, 2026 09:48 — with GitHub Actions Inactive
@hoegertn
Copy link
Copy Markdown

hoegertn commented Apr 1, 2026

Thanks you very much to both of you. I really appreciate the effort that you put into this feature.

I will definitely try it out immediately after release and change my pipelines.

Aghain, thanks a lot.

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.

(cli): Add cdk publish command for asset publishing

5 participants