faker icon indicating copy to clipboard operation
faker copied to clipboard

feat(workflows): Add release workflow

Open DaviDevMod opened this issue 2 years ago • 7 comments

Hello, I randomly stumbled in this issue #268 while I was taking a look at your project to get some inspiration.

For the past few days I've been dealing with automating the releases of one of my project and as soon I saw the issue, I thought I could give some help.

I just ported the changesets/changesets solution for my yarn workspaces to your pnpm project.

I did so with the help of some documentation:

I didn't fully tested the workflow because I would need a secrets.GITHUB_TOKEN and a secrets.NPM_TOKEN but I am confident that it should work. Give it a try.

The way this should work is that whenever you want to add a changeset, you run pnpm changeset and follow the instructions. Then commit the autogenerated changeset and push to main. The push triggers a release workflow that will create a PR with the changeset, or if there was a PR already open it will just add commits to that PR. Once you merge the PR, a new release of your package is automatically published to both NPM and GitHub.

You can customize stuff and probably you also want to adopt this beatiful changeset-bot.

DaviDevMod avatar May 10 '22 02:05 DaviDevMod

Codecov Report

Merging #942 (701b5ec) into main (fb55728) will decrease coverage by 0.00%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #942      +/-   ##
==========================================
- Coverage   99.65%   99.65%   -0.01%     
==========================================
  Files        1957     1957              
  Lines      209831   209831              
  Branches      878      877       -1     
==========================================
- Hits       209112   209109       -3     
- Misses        699      702       +3     
  Partials       20       20              
Impacted Files Coverage Δ
src/modules/finance/index.ts 99.31% <0.00%> (-0.69%) :arrow_down:

codecov[bot] avatar May 10 '22 02:05 codecov[bot]

I guess the prepublishOnly script could be removed. And you may also want to add some caching logic to the workflow, but I leave it up to you. It's a very light workflow which wouldn't even run as often as the others.

DaviDevMod avatar May 10 '22 19:05 DaviDevMod

Just to give you some feedback. We will discuss this in our team meeting next week (Thursday).

ST-DDT avatar May 11 '22 22:05 ST-DDT

@ST-DDT I do appreciate the feedback. Thank you.

DaviDevMod avatar May 12 '22 01:05 DaviDevMod

I currently not have the time to look into it to deep but one of my first questions would be if standard-version is still needed or if this also create it's own way of changelog 🤔

Not to fully count that this PR will get merged some day, but we should use node 18 instead of 16 and you are right about that we may remove the prepublishOnly and release step unless otherwise needed.

Shinigami92 avatar May 12 '22 11:05 Shinigami92

@Shinigami92 yes it creates changelogs. I believe it would just add new ones at the top of your existing CHANGELOG.md

When you push a commit that has a new changeset, it gets committed as usual, but the workflow sees there is a new changeset and creates (or updates) a PR which contains:

  • the various additions to the CHANGELOG.md
  • the removal of all the changesets
  • a version bump in package.json

You can modify the PR in any way, like editing the changes or the title.

Once the PR is merged you get the updated CHANGELOG.md and the version bump in main. The changesets are gone and a new release will be found on NPM and GitHub.

Now that I think about it, the workflow can run just for .changeset/**, there is no need for that CHANGELOG.md. I am going to modify the paths in the workflow and apply the changes you mentioned.

DaviDevMod avatar May 12 '22 16:05 DaviDevMod

By the way I played around on my fork trying to publish a release, but the workflow keeps trying to release at faker-js rather than davidevmod, and obviously fails because it doesn't have the permission. Probably it's just a question of modifying names in the package.json but I don't care that much, the PR gets generated so the workflow is probably fully functional.

DaviDevMod avatar May 12 '22 16:05 DaviDevMod

We will stay with the current way of generating changelogs. Also this gotten stale, so closing for now.

ST-DDT avatar Sep 08 '22 16:09 ST-DDT

That's alright, hope you find a workflow that fits your needs.

DaviDevMod avatar Sep 08 '22 17:09 DaviDevMod