Sub topic 10
Promoting a Version to Released
This chapter assumes you can already build a package version with sf package version create and that your sfdx-project.json is set up for a managed package. Here you will learn what separates a beta version from a released one, how to promote a version, and what promotion locks in.
Beta and released versions
Every package version you create starts as a beta. A beta version can be installed in sandboxes, scratch orgs, and Developer Edition orgs. It cannot be installed in production orgs, and it cannot be listed on AppExchange.
A released version is one you have promoted. Promotion marks the version as production-ready, so it can be installed in any org. It is also the only kind of version that can be submitted for security review.
Promotion cannot be undone. After you promote a version, you cannot change its contents, and you cannot return it to beta. You can only delete a released version if it has never been installed by a subscriber. If a promoted version has a defect, you fix it in a new version.
| Property | Beta | Released |
|---|---|---|
| Install in sandbox or scratch org | Yes | Yes |
| Install in production | No | Yes |
| Eligible for AppExchange | No | Yes |
| Can be deleted | Yes | Only if no subscriber has installed it |
| Managed-package rules apply to later changes | No | Yes |
Before you promote
Check these items first:
- The version was built with
--code-coverage. Promotion fails if the version has not had its code coverage calculated. - Code coverage for the package is at least 75 percent.
- You installed and tested the exact beta version in a scratch org or sandbox.
- The version number and
ancestorVersionare correct. Both are fixed once you promote.
Promote the version
Use the alias or the 04t subscriber package version ID:
sf package version promote --package [email protected] --target-dev-hub devhubThe CLI asks you to confirm the promotion. Add --no-prompt to skip the question, which is useful in automation.
Check the result with the list command:
sf package version list --packages AcmeApp --released --target-dev-hub devhubThe output includes a Released column, which shows true for the promoted version.
Why promotion matters for later work
Promoting a version makes later builds subject to the managed-package rules. For example, if a later version sets ancestorVersion to a released version, the build is checked against that version's components. It will fail if you remove a global Apex class or change a global method signature that the released version exposed.
Only one version in a major.minor.patch line can be released. If you promote 1.0.0-1, you cannot also promote 1.0.0-2. Increment the minor or patch number for your next release.
Common errors
- Code coverage requirement not met: Rebuild the version with
--code-coverageand add tests until coverage reaches 75 percent. - Version already released: Another build with the same major.minor.patch is already promoted. Increase the version number and rebuild.
- Wrong Dev Hub: The command can only see packages owned by the Dev Hub in
--target-dev-hub. Confirm the alias.
Exercise
A teammate built [email protected], found a bug after installing it in a sandbox, and fixed it in source. They ask you to promote 1.0.0-3 anyway, since the fix is small. What should you do?
Show answer
Do not promote it. The fix is not in that build, because a beta cannot change after it is created. Build a new version with sf package version create --code-coverage, test that new beta, and promote it. Promotion is permanent, so promote only a build you have tested.