Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup npm auto deprecate workflow #6520

Merged
merged 3 commits into from
Aug 25, 2021
Merged

ci: setup npm auto deprecate workflow #6520

merged 3 commits into from
Aug 25, 2021

Conversation

favna
Copy link
Contributor

@favna favna commented Aug 24, 2021

Please describe the changes this PR makes and why it should be merged:

TL;DR: Script to automatically deprecate older npm versions, runs on a cron job of 01:00 UTC


Quite a while ago now, around the time we introduced auto published dev builds, we had a discussion in prof chat about how to handle old "dev" versions. From that spawned changes to the dev publisher to first deprecate and then publish a new version. A near perfect solution, but as seen at the time of writing, not a flawless one. This what NPM versions tab currently looks like:

image

Back then I mentioned how I would be working on a utility that could automatically deprecate versions as based on what I could get as info from registry.npmjs.com. Well I finally had time to make it now that I have vacation, so here it is.

This new workflow will run every night at 01:00 UTC. It scans all the versions that are on NPM and filters out those that:

  • are not the "latest" tag
  • do not have a dist tag associated with them
  • are not already deprecated
  • match the glob provided by the --name option (uses the micromatch lib)

So given the earlier screenshot that means that only the boxed version would get matched and deprecated with this script:

image


As as aside, this CLI tool can also be used to manually bulk deprecate versions if needed in the future (i.e. deprecating whole v13 when we go v14 with --name "13*") but just keep in mind that it is not capable of prompting for NPM OTP so it must be used with an NPM Automation Token in your Env vars as NODE_AUTH_TOKEN

I have tested the CLI tool against all of Sapphire's current packages, successfully deprecating many old versions there.


Lastly, for now I pass the options as CLI flags. The tool can also read a JSON or YAML config file in the project root, so if that is preferable let me know and I'll make the change.


Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@ImRodry
Copy link
Contributor

ImRodry commented Aug 25, 2021

Shouldn’t you remove the auto deprecate step in publish-dev then? Or is this just to make sure no versions are left over?

@favna
Copy link
Contributor Author

favna commented Aug 25, 2021

@ImRodry That's a possibility. For now it's an extra step to clean up remainders. Whether to remove that step is something I first want to hear @iCrawl's thoughts on.

.github/workflows/auto-deprecate.yml Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 49e3a14 into discordjs:main Aug 25, 2021
@favna favna deleted the ci/setup-npm-auto-deprecate-workflow branch August 26, 2021 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants