How to execute 'npm script' within github action and use the script output as a package source
kuncevic opened this issue · 2 comments
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:
ng build --prod
cd dist/library-name
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?
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!
Just tested out by following the steps:
- prepublish script https://github.com/kuncevic/rx-service/blob/master/package.json#L11
- workspace dir https://github.com/kuncevic/rx-service/blob/master/.github/workflows/npm-publish.yml#L23
- release commit angularconsulting/rx-service@b34eefd
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