drone-plugins / drone-npm

Drone plugin for publishing packages to NPM
http://plugins.drone.io/drone-plugins/drone-npm
Apache License 2.0
20 stars 18 forks source link

Plugin is broken due to npm's new authToken requirements #58

Closed dessalines closed 2 years ago

dessalines commented 2 years ago

As of a few months ago, npm starting requiring auth tokens rather than logins, to be able to publish there, which broke this plugin. Took me a while to figure out a simple solution, but here it is for anyone who finds it useful:

  - name: npm publish
    image: node:17-alpine
    commands:
      - echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> .npmrc
      - echo "email = $NPM_EMAIL" >> ~/.npmrc
      - npm publish
    environment:
      NPM_AUTH_TOKEN:
        from_secret: npm_token
      NPM_EMAIL: MY_EMAIL
    when:
      ref:
        - refs/tags/*
bradrydzewski commented 2 years ago

the plugin supports token authentication using the token attribute

we have been using token for authentication internally with success, so unfortunately we are unable to reproduce this issue. however, if you continue to experience issues we would happily accept a pull request.

dessalines commented 2 years ago

All current npm publish's are failing with this error:

time="2022-01-09T15:50:59Z" level=error msg="validation failed: registry values do not match .drone.yml: https://registry.npmjs.org/:_authToken=$NPM_TOKEN package.json: https://registry.npmjs.org/:_authToken=$npm_token"