I updated the package for GitHub Actions for getting package info.
Version 1.1 has a new output value is-release-candidate
. The step of publishing a package using workflow is now easier. You can publish a release version on a par with a release version using the "next" and "latest" tags.
Usually a package has only one default tag "latest". Each new version becomes the latest and used by default as new.
But if you want to deploy beta versions before the main release, you should use separate tag. Next, beta or alpha — name it as you want.
Look at the releases flow diagram. This way Editor.js is releasing. Latest version is a stable release. Next version gets updates first. It contains release candidates version "rc".
This way users may choose which version they want to use and pull updates:
- npm i @latest
- npm i @next
Next version contains each release. Therefore we should publish every version with the "next" tag. "Latest" tag should be only on non-rc versions.
For a few our projects I use the same workflow to deploy node packages to NPM:
- trigger workflow on push to the main branch;
- prepare dev environment;
- install dependencies and build the package if it is required;
- publish package to npm with "next" tag;
- if the version is not RC then add tag "latest" to published package.
name: Publish package to NPM
on:
push:
branches:
- main
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: yarn
- run: yarn build
- run: yarn publish --access=public --tag=next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get package info
id: package
uses: codex-team/[email protected]
- name: Add LATEST tag for the published package if this is not a -rc version
if: steps.package.outputs.is-release-candidate == 'false'
run: npm dist-tag add ${{ steps.package.outputs.name }}@${{ steps.package.outputs.version }} latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Next time I'll say how to set up auto bumping version in pull requests.
Happy coding and stay tuned.