Skip to content

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. Its 0Ho ID is the checkr entry in packageAliases in sfdx-project.json.
  • Contents: everything under sfdx-source/checkr, the default package directory, including @IsTest classes.
  • Not packaged: sfdx-source/reference (the Account trigger shim, smoke seeds, and *IT integration tests). It is a second, unpackaged directory with no package key. Subscribers write their own trigger shims from installation.

The package was created once, by hand:

Terminal window
sf package create --name checkr --package-type Unlocked \
--path sfdx-source/checkr --no-namespace --json

No 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 use ckr);
  • names are PascalCase after 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

  • versionNumber in sfdx-project.json is major.minor.patch.NEXT. Each sf package version create takes the next build number, so betas of 0.1.0 are 0.1.0.1, 0.1.0.2, and so on. From 0.1.2 on, major.minor.patch matches the source release tag that ships it; see Keep versions in sync.
  • sf records each version as an alias in packageAliases, for example checkr@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 (or major) for a release with breaking changes, and patch for fixes, before cutting the version. Only one version per major.minor.patch can 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:

  1. Bump. On a branch, set versionNumber to the next version (for example 0.1.5.NEXT for the next patch) and set versionName to match. Merge the PR.

  2. Cut. From updated master, publish sf beta (see Cut a beta).

  3. Test. Run install-smoke and install-upgrade from the previous promoted 04t, each in a fresh scratch org (see Evidence). Commit the evidence on the chore/package-<version> branch and merge the PR.

  4. Promote the beta (see Promote a version).

  5. Publish. From updated master:

    Terminal window
    publish --dry-run -m "feat: release <version>" --package <04t> --push-public
    publish -m "feat: release <version>" --package <04t> --push-public

    publish confirms the version is promoted and takes the patch, minor, or major bump from it. In the source release commit it marks the version.json released, points the README and installation at the new 04t, and puts the package under the matching changelog heading.

  6. Website. The site’s daily update-product-versions workflow reads the new GitHub release and its version.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):

Terminal window
publish sf beta --dry-run # git checks, then prints the sf commands
publish sf beta

It 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.json from the script;
  • a passing install-smoke run of the version, in a fresh scratch org;
  • when an earlier promoted version exists, a passing install-upgrade run from it;
  • a CHANGELOG.md entry for the version, with its 04t ID.
Terminal window
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:

Terminal window
sf package version promote --package <04t> --target-dev-hub devHub --no-prompt --json
sf package version report --package <04t> --target-dev-hub devHub --json # IsReleased: true

Then 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.