This version is forked and modified from plugins/npm.
It implements npm publish, supporting both official repositories and private repositories.
Adjustments:
username: string Usernamepassword: string Passwordtoken: string Authentication via tokenemail: string Emailregistry: string Registry, default: https://registry.npmjs.org/folder: string Directory to publish, default is current directory.fail_on_version_conflict: boolean Exit with error when version existstag: string NPM publish tag --tagaccess: string NPM scoped package access --access$:
# Triggered on tag push
tag_push:
- docker:
image: node:22-alpine
stages:
- name: update version
# Modify version in package.json to current tag, but won't commit code
script: npm version $CNB_BRANCH --no-git-tag-version
- name: npm publish
image: tencentcom/npm
settings:
username: $CNB_TOKEN_USER_NAME
token: $CNB_TOKEN
email: $CNB_COMMITTER_EMAIL
registry: https://npm.cnb.cool/xxx/xxx/-/packages/
folder: ./
fail_on_version_conflict: true
When pushing to the official repository, you cannot use a password; you must authenticate with a token.
npm-token.yml file, then import it using imports.# npm-token.yml
NPM_USER: your-username
NPM_TOKEN: your-token
NPM_EMAIL: your-email@email.com
main:
push:
- stages:
- name: npm publish
image: tencentcom/npm
imports: https://cnb.cool/xxx/npm-token.yml
settings:
username: $NPM_USER
token: $NPM_TOKEN
email: $NPM_EMAIL
folder: ./
fail_on_version_conflict: true
docker run --rm \
-e PLUGIN_USERNAME=xxx \
-e PLUGIN_TOKEN=xxx \
-e PLUGIN_EMAIL=xxx@xxx.com \
-v $(pwd):$(pwd) \
-w $(pwd) \
tencentcom/npm