A GitHub Action to delete specific versions of packages from GitHub Packages. Supports both user and organization-owned packages.
- Delete specific versions from GitHub Packages
- Supports multiple package types:
npm,maven,rubygems,docker,nuget,container - Works with both user and organization-owned packages
- Handles multiple packages and versions in a single run
- Gracefully handles missing packages/versions (logs warning and continues)
- Automatically deletes entire package when removing the last remaining version
Add the following step to your workflow:
- uses: wherobots/delete-package-versions@v1
with:
package_type: maven
packages: com.wherobots.artifact1,com.wherobots.artifact2
versions: 0.1.0-SNAPSHOT,0.2.0-SNAPSHOT
github_token: ${{ secrets.GITHUB_TOKEN }}| Input | Required | Default | Description |
|---|---|---|---|
package_type |
Yes | - | The type of package: npm, maven, rubygems, docker, nuget, or container |
packages |
Yes | - | Comma-separated list of package names to delete versions from |
versions |
Yes | - | Comma-separated list of versions to delete |
owner |
No | Current repo owner | Owner (user or org) of the packages. Defaults to the owner of the repo running the action |
github_token |
No | ${{ github.token }} |
A GitHub token with packages:delete permission |
- uses: wherobots/delete-package-versions@v1
with:
package_type: maven
packages: com.example.my-lib,com.example.my-utils
versions: 1.0.0-SNAPSHOT,2.0.0-SNAPSHOT- uses: wherobots/delete-package-versions@v1
with:
package_type: container
packages: my-app
versions: sha-abc123,sha-def456
owner: my-organization- uses: wherobots/delete-package-versions@v1
with:
package_type: npm
packages: "@myorg/my-package"
versions: 0.0.1-beta.1,0.0.1-beta.2
github_token: ${{ secrets.PACKAGES_TOKEN }}The github_token needs the following permissions:
packages: write(for deleting package versions)read:packages(for listing package versions)
If using the default GITHUB_TOKEN, ensure your workflow has these permissions:
permissions:
packages: write- Node.js 20 or later
git clone https://github.com/wherobots/delete-package-versions.git
cd delete-package-versions
npm installnpm testSince this is a GitHub Action, every commit that changes code must include an updated bundle. Generate a new bundle with:
npm run packageThen commit the resulting changes in the dist/ folder.
This project uses ESLint for linting and Prettier for formatting.
# Check for lint errors
npm run lint
# Auto-fix lint errors
npm run lint:fixReleases are created by tagging a new version:
git checkout main
git fetch origin
git pull
# Bump version (patch, minor, or major)
npm version <patch|minor|major>
# Push with tags
git push --follow-tagsThis updates package.json, creates a commit, and creates a Git tag. The --follow-tags flag ensures the tag is pushed.
ISC