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

Added support for setting tag on npm publish #25

Closed foopoiuyt closed 7 years ago

foopoiuyt commented 7 years ago

We've run into situations where we wish to push pre-release versions of npm packages from drone updating a separate dist-tag (like beta, test or pre-release) rather than latest.

foopoiuyt commented 7 years ago

Added --access as well.

donny-dont commented 7 years ago

LGTM

shynome commented 6 years ago

how to use it ? In the document I can't find anything about set publish tag,

like 0.0.0-0 I want to publish as tag beta , I can't find a param to publish beta tag

tboerger commented 6 years ago

Just set the tag Attribute within your drone config

shynome commented 6 years ago

can I set a npm publish tag to a file , just like plugins/docker if .tags file exist get tags from the .tags file

like the sample, if get a tag from '.npm_tag' file will be easy, I can add a preset step to set npm publish tag

pipeline:

  # tag: 1.0.1-0
  npm_publish: &npm_publish
    when: { event: tag }
    image: plugins/npm
    username: shynome
    email: shynome@gmail.com
    secrets: [ npm_token ]
    tag: beta
  # tag: 1.0.1
  npm_dev_publish:
    when: { event: tag }
    <<: *npm_publish
    tag: latest

  preset:
    image: node
    commad:
      - |
        node -e '
        let [ version, suffix ] = require("./package.json").version.split('-');
        require("fs").writeFileSync(".npm_tag",suffix?"beta":"latest");
        '
tboerger commented 6 years ago

This is not implemented.

shynome commented 6 years ago

Thanks. It doesn't look very difficult, I will try to implement this interface

I also found the project sitll has two open issues from 2017-08 , that's also helpful , anyone can deal that ?

tboerger commented 6 years ago

So far nobody volunteered for the open issue. The documentation issue could be eventually already solved, I have not checked that.

shynome commented 6 years ago

Finally, I found a way to resolve my problem by use commads option.

( I feel the solution is not bad )

pipeline:
  npm_publish:
    when: { event: tag }
    image: plugins/npm
    secrets: [ npm_token ]
    environment:
      PLUGIN_USERNAME: npm_user
      PLUGIN_EMAIL: npm_user@email.com
    commands:
      - /bin/drone-npm --tag $(node -pe "/-/.test(require('./package').version)?'beta':'latest'")