Skip to content

teppeis/guess-npm-dist-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

guess-npm-dist-tag

Automatically determine the dist-tag from the current latest and the new version number when npm publish.

npm version supported Node.js version ci status license

Usage: CLI

$ npx guess-npm-dist-tag
latest

Compare the version number of the local package.json in CWD with the latest version retrieved from the npm registry and output the most appropriate dist-tag like latest, latest-3ornext.

You can use this with npm publish --tag in GitHub Actions.

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v3
    with:
      node-version: "20.x"
      registry-url: "https://registry.npmjs.org"
  - run: npm ci
  - run: npm publish --tag $(npx guess-npm-dist-tag)
    env:
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

See setup-node and "Publishing Node.js packages" in GitHub Docs.

License

MIT License: Teppei Sato <teppeis@gmail.com>

About

Automatically determine the dist-tag from the current latest and the new version number when `npm publish`.

Topics

Resources

Stars

Watchers

Forks