Package retention¶
Package retention deletes older package versions from a feed. Use it to keep only the newest stable and prerelease versions for each package id.
Warning
Pruned packages are deleted from the feed. Sleet does not support unlisting. Deleting packages can break restores for consumers that pin those versions. Test with --dry-run first and take a backup before pruning.
How retention works¶
Retention keeps the newest N stable versions and M prerelease versions per package id. Versions beyond those limits are removed from the feed, including matching symbol packages when present.
Automatic pruning runs on sleet push only when both retention settings are present and greater than zero:
retentionmaxstableversionsretentionmaxprereleaseversions
Packages pushed by the current push command are pinned for that push and are never pruned by the same push. Automatic pruning only checks package ids included in the push.
Sleet can also group prerelease versions by the first prerelease labels before applying the prerelease limit. That setting is stored as retentiongroupbyfirstprereleaselabelcount.
See feed settings for the setting keys.
Retention settings¶
Use sleet retention settings to store automatic retention settings in the feed.
This updates sleet.settings.json. Future pushes apply the settings automatically. Run sleet retention prune if you want to apply the settings to packages already on the feed immediately.
Disable automatic pruning:
See the command reference for all options.
Retention prune¶
Use sleet retention prune for a one-off prune. If you omit --stable, --prerelease, or --release-labels, Sleet uses the values stored in feed settings.
Apply stored settings:
Override the limits for this run:
Prune only selected package ids:
Preview changes without deleting packages:
See the command reference for all options.
Retain packages by release labels¶
Use --release-labels when prerelease versions contain labels for branches, channels, or build groups.
Example package versions:
1.0.0-beta.branch.a.build.100
1.0.0-beta.branch.a.build.101
1.0.0-beta.branch.a.build.102
1.0.0-beta.branch.a.build.103
1.0.0-beta.branch.z.build.205
1.0.0-beta.branch.z.build.206
1.0.0-beta.branch.z.build.207
1.0.0-rc.branch.a.build.308
To keep one prerelease from each group based on the first three release labels, run:
Or store the setting for future pushes:
Sleet groups prerelease packages by VERSION-FIRST.SECOND.THIRD.*. The major, minor, and patch parts of the version are used for ordering, but not for choosing groups. In this example, all prerelease packages with beta.branch.a are grouped together and only the highest version remains.
After pruning, these versions remain: