single-spa / single-spa-react

Single-spa lifecycles helper for React applications
https://single-spa.js.org/docs/ecosystem-react.html
MIT License
226 stars 63 forks source link

Add automated release workflow #178

Closed robmosca closed 1 year ago

robmosca commented 1 year ago

This PR is a proposal to introduced automated publishing of the package.

This should prevent problems like the ones observed in the last two minor versions of the package.

It uses the Changesets Release Action and works in the following way:

  1. As a contributor, when I open a PR I always have to remember to add the corresponding changeset (by using pnpm changeset)
  2. The PR itself will run a job to build, lint and test the code. The maintainers of this repository can add this job as a required job to be able to merge the PR. In this way, if a PR does not pass any of the steps (build, check-format, lint, test) it won't be possible to merge it
  3. When the PR is merged to the main branch, the changesets/action will find that there is a changeset file, and will open a PR to publish the package. This PR is the result of running pnpm changeset version on the code in the main branch.
  4. If other PRs are merged from other contributors, the changesets files will accumulate and the PR opened at step 3 will be updated including all contributions
  5. Once the maintainers are ready to release the package, they just have to merge the release PR. This time, the changesets/action, seeing that there is no changeset file anymore, will publish the package to NPM and create a release with the corresponding release notes in GitHub

For this to work it is necessary that:

  1. The GITHUB_TOKEN is granted permissions to create and approve pull requests. This can be done in Settings -> Actions -> General -> Workflow permissions -> Allow GitHub Actions to create and approve pull requests
  2. The maintainers create an NPM_TOKEN secret with an NPM token with write permissions to the organization (or at least the corresponding package, for publishing).