Skip to content
CodeFloe

Container Package Cleanup

  1. Open the settings for the user or organization that owns the container packages.

    • Organization packages: Open the organization, then go to Settings → Packages → Cleanup rules.
    • Personal packages: Open your avatar menu, then go to Settings → Packages → Cleanup rules, or open your package settings directly.
  2. Click Add cleanup rule to create a rule, or select an existing Container rule to edit it.

Cleanup rules apply to packages owned by that user or organization, including packages linked to repositories. See the Forgejo cleanup rules documentation for more details.

Retain release tags while removing other versions

Section titled “Retain release tags while removing other versions”

A container package cleanup rule can remove temporary tags, such as commit hashes or branch names, while keeping tags based on semantic versions.

Illustration of a container cleanup rule with one recent version retained, a release-tag keep expression, and all other versions selected for removal.

Illustration of the example configuration after enabling the rule; the appearance of the Forgejo form may differ.

For example, configure a cleanup rule with the following settings:

SettingValue
EnabledUnchecked until after saving and reviewing the preview
TypeContainer
Apply pattern to full package nameUnchecked
Keep the most recent1 version per package
Keep versions matchingUse the expression below
Remove versions older thanLeave empty
Remove versions matching.*

Enter this regular expression in Keep versions matching:

^(v.*|2|3|[0-9]+(\.[0-9]+){1,2}(-[0-9A-Za-z.-]+)?([+][0-9A-Za-z.-]+)?)$

This keeps tags such as 1.2, 1.2.3, and 1.2.3-rc.1, along with all tags starting with v and the bare major-version tags 2 and 3. Adjust the 2|3 alternatives to match the major-version tags you publish. The pattern is deliberately broader than strict SemVer: v.* also retains tags such as v-next.

Keep rules take precedence over removal rules, so .* removes only versions that are not protected by a keep rule. The most recent version per package is retained, and the latest tag is always kept for Container packages.