Packaging and releases
How the checkr package is built and versioned, and what a version needs
before it is promoted. Admins installing CheckR want
installation. Source snapshots are described in
release.
The package
- Type: unlocked second-generation package (2GP) named
checkr, owned by the maintainers’ Dev Hub. Its0HoID is thecheckrentry inpackageAliasesinsfdx-project.json. - Contents: everything under
sfdx-source/checkr, the default package directory, including@IsTestclasses. - Not packaged:
sfdx-source/reference(the Account trigger shim, smoke seeds, and*ITintegration tests). It is a second, unpackaged directory with nopackagekey. Subscribers write their own trigger shims from installation.
The package was created once, by hand:
sf package create --name checkr --package-type Unlocked \ --path sfdx-source/checkr --no-namespace --jsonNo namespace
CheckR has no namespace, so subscriber code calls CKR_ChecklistTriggerGateway
and queries CKR_ objects without a prefix, and the package can be developed
and tested in any org. The cost is that nothing reserves CheckR’s API names in a
subscriber org. The CKR_ prefix stands in for a namespace:
- every packaged API name and DeveloperName starts with
CKR_(LWCs useckr); - names are
PascalCaseafter the prefix; - never use
CKR_for subscriber-owned metadata such as trigger shims and their tests, so they can’t collide with a later package version.
A namespace can’t be added to an existing package. Moving to one later means a new package and a data migration.
Versions
versionNumberinsfdx-project.jsonismajor.minor.patch.NEXT. Eachsf package version createtakes the next build number, so betas of 0.1.0 are0.1.0.1,0.1.0.2, and so on. From 0.1.2 on,major.minor.patchmatches the source release tag that ships it; see Keep versions in sync.sfrecords each version as an alias inpackageAliases, for examplecheckr@0.1.0-1. Commit those aliases; they are the record of what exists.- The changelog heading for a beta uses the alias form:
## [0.1.0-1] - <date>. - Raise
minor(ormajor) for a release with breaking changes, andpatchfor fixes, before cutting the version. Only one version permajor.minor.patchcan be promoted. - Every version starts as a beta, which installs only in scratch orgs and sandboxes. Promoting it (see Promote a version) makes it installable in production.
Code coverage
Version creation runs with --code-coverage. A beta can be created with any
coverage, but a version needs 75% coverage of packaged Apex to be promoted.
CheckR holds itself to more: the real-org apex-local-tests scenario fails
below 85% org-wide coverage or 75% coverage of sfdx-source/checkr Apex.
Check its latest run before cutting a version.
Fields are hard to remove
Once a version containing a field, object, or global Apex signature is installed anywhere, removing it from a later version only deprecates or deletes it on upgrade, and subscriber metadata that references it blocks the upgrade. Add schema deliberately, and remove unused schema before the first version that ships it, as was done for the auto-create fields before 0.1.0.
Keep versions in sync
For a package-backed release, one number names the release everywhere: the package version
(major.minor.patch of versionNumber), the source tag and package.json
version, the newest released changelog heading, and the 04t that the README
and installation point at. The publish release tool
(its sf2gp adapter, configured in release.config.mjs) keeps them in sync.
publish sf check checks that they agree. It needs no Dev Hub login, and
publish sf beta and publish --package run it before they change anything.
A source-only release consumes its source version in the tag, changelog, and
package.json. The promoted package, its install ID, and the package
versionNumber in sfdx-project.json may stay at the prior package version
until work begins on the next package beta. Source-only 0.1.4 left the
installable package at 0.1.3. The next package-backed release must use 0.1.5
or higher, depending on the release scope.
Release in this order, one step at a time:
-
Bump. On a branch, set
versionNumberto the next version (for example0.1.5.NEXTfor the next patch) and setversionNameto match. Merge the PR. -
Cut. From updated
master,publish sf beta(see Cut a beta). -
Test. Run
install-smokeandinstall-upgradefrom the previous promoted04t, each in a fresh scratch org (see Evidence). Commit the evidence on thechore/package-<version>branch and merge the PR. -
Promote the beta (see Promote a version).
-
Publish. From updated
master:Terminal window publish --dry-run -m "feat: release <version>" --package <04t> --push-publicpublish -m "feat: release <version>" --package <04t> --push-publicpublishconfirms the version is promoted and takes the patch, minor, or major bump from it. In the source release commit it marks theversion.jsonreleased, points the README and installation at the new04t, and puts the package under the matching changelog heading. -
Website. The site’s daily
update-product-versionsworkflow reads the new GitHub release and itsversion.json; run it by hand to update at once.
Changes that touch only the docs or tooling do not need a package release.
For a source-only release, pass --source-only instead of --package. The
docs site rebuilds on each source release.
Cut a beta
From a clean checkout of a commit on origin/master, with the Dev Hub
authenticated as devHub (or set DEVHUB_ALIAS):
publish sf beta --dry-run # git checks, then prints the sf commandspublish sf betaIt checks the versions, creates the beta with
sf package version create --package checkr --installation-key-bypass --code-coverage, writes docs/evidence/releases/<version>/version.json (the
version, 04t, 05i, alias, commit, coverage, and the beta install URL for
sandboxes and scratch orgs), and commits it with the new packageAliases
entry on a new chore/package-<version> branch. It never pushes or promotes.
--no-branch leaves the changes uncommitted.
Evidence before sharing a version
A version is not promoted or shared until its release branch has:
docs/evidence/releases/<version>/version.jsonfrom the script;- a passing
install-smokerun of the version, in a fresh scratch org; - when an earlier promoted version exists, a passing
install-upgraderun from it; - a
CHANGELOG.mdentry for the version, with its04tID.
npm run org:evidence -- --scenario install-smoke --org <scratch> --package <04t>npm run org:evidence -- --scenario install-upgrade --org <scratch> \ --package <04t> --upgrade-from <previous 04t>Each install scenario installs the package itself and must run alone, in its own
fresh scratch org. They refuse checkr-evidence and any non-scratch org.
Creating a scratch org (--create-scratch) needs the maintainer’s explicit
confirmation. See scenario details.
Commit the evidence folders on the release branch and open a PR.
Promote a version
Promotion releases a version for production installs. It cannot be undone,
and only one version per major.minor.patch can be promoted, so promote only
a version whose evidence is complete:
sf package version promote --package <04t> --target-dev-hub devHub --no-prompt --jsonsf package version report --package <04t> --target-dev-hub devHub --json # IsReleased: trueThen release it with publish --package <04t> (step 5 of
Keep versions in sync). If a release fails after
promotion, publish sf record <04t> records the version in the working tree;
commit that before running publish --package again.