How do you combine semantic-release with build-once container deployments?

November 16, 2026 5 answers
Asked by Zavelo-3h

I use semantic-release with prerelease branches for infrastructure, but I’m not sure how to apply it to an application container. I want to test an image in dev and then promote that exact image through testing and production without rebuilding it.

Should the stable version be created before dev testing or only after a candidate is validated? How do you handle fixes and new changes arriving on the main branch?

Answers

q.275!plaidwicket

Treat the image digest as the artifact identity and the semantic version as a label. Build an image for a commit, record its digest, and deploy that digest to dev. After validation, add the release tag to the same image without rebuilding it, then promote that digest through testing and production.

Make sure the image you promote was built from the commit you intend to release. A feature-branch build might not contain the same content as the eventual merge commit, so don’t assume the two are interchangeable. When copying between registries, verify the destination digest before deploying it.

Zavelo-3h:

So newer commits on main wouldn’t change the candidate already being tested?

6q+gaugecradle_318:

Right. Record the candidate’s commit and digest when you select it. New merges can produce other images, but they don’t replace that candidate unless you explicitly select a new one.

Reply to this answer
Kervan+2w

You can also let semantic-release create stable versions as changes land on main, then promote whichever version passes testing. A version doesn’t have to reach production just because it exists. If a dev test finds a bug, release the fix as another version and test that image instead.

This is simpler if you’re comfortable with gaps between the versions in production. If every stable version has to mean production-ready in your process, delay the stable label until validation instead.

Reply to this answer
Navori.6t

For trunk-based development, main can continuously deploy to dev while a chosen commit and image digest become the release candidate. Test that fixed candidate in staging, then require approval before promoting it to production. Main can keep moving without silently changing what’s under review.

There is a catch: a shared dev environment may move on while someone is validating a candidate. You’ll need to coordinate that validation or give the candidate a separate place to run. Feature flags can also help keep unfinished work from being exposed, but they don’t replace selecting an exact artifact.

Reply to this answer
3c+modharbor_719

If main often contains changes that aren’t ready to ship, a release branch is another option. Select a commit for the branch, build its candidate image, and promote that image after staging. Fixes on the release branch produce new candidates that need testing again. That still avoids rebuilding the same candidate for each environment.

This gives you a controlled place for release fixes, though it adds branch management and is a different workflow from promoting an image already tested from main.

Reply to this answer
_w39+tagwhistle.6

The same digest is only part of the story. Configuration, feature flags, database schemas, and downstream services can differ between environments, so a successful dev test doesn’t prove production compatibility.

Keep environment-specific settings outside the image and record what was tested alongside the digest. Check production configuration and migrations as part of the release approval too.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions