pascalgn / npm-publish-action

GitHub action to automatically publish packages to npm
MIT License
221 stars 29 forks source link

How to execute 'npm script' within github action and use the script output as a package source #16

Open kuncevic opened 4 years ago

kuncevic commented 4 years ago

I have a library that I build with Angular CLI here https://github.com/kuncevic/rx-service In order to release a new version of the library manually I had to to this steps:

  1. ng build --prod
  2. cd dist/library-name
  3. npm publish

It just can be looks like a single npm script "publish": "ng build --prod && cd dist/library-name && npm publish"

I want to release that library using github actions so the steps above needs to be executed within an action, by looking in to npm-publish-action but didn't found a way to achieve that.

Any ideas?

pascalgn commented 4 years ago

I think it might be enough to add this to the prepublish step (see https://docs.npmjs.com/misc/scripts) in package.json like this:

  "scripts": {
    "prepublish": "ng build --prod"
  }

Regarding the cd dist/library-name part, this is implemented in #15, I will have a look at it now!

kuncevic commented 4 years ago

Just tested out by following the steps:

  1. prepublish script https://github.com/kuncevic/rx-service/blob/master/package.json#L11
  2. workspace dir https://github.com/kuncevic/rx-service/blob/master/.github/workflows/npm-publish.yml#L23
  3. release commit https://github.com/kuncevic/rx-service/commit/b34eefdc1ed72436043270a7eecd7e73e4830b2d

In result I've got the action triggered https://github.com/kuncevic/rx-service/actions/runs/186705728 but nothing was pushed to npm ref: npm show rx-service time and https://www.npmjs.com/package/rx-service still show that 0.0.6 is the latest version

UPDATE: Tried again with 0.0.8 but on way so just had to push the new version manually after all