meszaros-lajos-gyorgy / minimist-lite

parse argument options
Other
15 stars 3 forks source link

Automate publishing on NPM registry using GitHub Actions. And add CI workflow #15

Closed micalevisk closed 2 years ago

micalevisk commented 2 years ago

Currently only you (I guess) can release new versions of this package.

We could use GitHub actions to automatically publish new versions to NPM registry after some event on this repo.

My proposal: publish on new releases on this repo.
An example of an workflow that publish the package on new Git Tags (that could be easily adapted): https://github.com/micalevisk/nestjs-swagger-api-http-response-decorators/blob/main/.github/workflows/publish-on-new-tag.yml

You just need to add a secret called NPM_TOKEN with your NPM access token into this repo.


Also, to make thinks more safer, we can add another CI workflow that will be triggered on every PR that change some code. It will ran automated tests & coverage report. So we'll make sure that only good PRs are merged to the main branch.


To implement this, I need to know a bit more about how is the current workflow from changing the code til release a new version.

meszaros-lajos-gyorgy commented 2 years ago

I've created an automation token on npm and added it here as a repository secret, so that part should be good to go. If that is not good or github actions can't use it, then I can move it to the environment secrets section.

meszaros-lajos-gyorgy commented 2 years ago

My current method for publishing new versions is:

  1. I get everything merged into master
  2. I run npm run build to create a freshly bundled code into /index.js
  3. I run npm run test to see if everything still works
  4. I commit the new build, if it changed from what is already in the master
  5. I run npm version minor when there are new features or npm version patch if there are only bugfixes, which will update the package.json, create a commit and create a new tag. If I want to test out the release procedure, then I create a beta release based on this document: https://kevinkreuzer.medium.com/publishing-a-beta-or-alpha-version-to-npm-46035b630dd7
  6. I push everything with git push --follow-tags
  7. I publish the new version to npm using npm publish
  8. After that I go to github's releases section and create a new release manually based on the latest tag.
meszaros-lajos-gyorgy commented 2 years ago

I think the release part of github action should only run when a new tag is created. For the record, this is what I do in my other repo: https://github.com/meszaros-lajos-gyorgy/arx-level-generator/blob/master/.github/workflows/build.yml