-
Notifications
You must be signed in to change notification settings - Fork 326
Description
We're using changesets in a large monorepo, where we are also using the GitHub Merge Queue feature. This is a feature that allows engineers to queue their PRs to be merged to the main
branch, and the queue handles merging all the branches with the latest main
, in addition to merging them into each other (i.e. main and first PR into second PR; main, first PR and second PR into third PR, and so on).
Problem
- An engineer opens PR A, it includes a changset. It is added to the merge queue.
- PR A is merged into master.
- While that was happening, someone opens PR B (also including a changeset).
- When PR A hit master, it triggered a
release.yml
workflow to run, which has created a "Version packages" PR. - PR B is added to the merge queue (position in the queue: 1).
- The "Version packages" PR is also added to the merge queue (position in the queue: 2).
- PR B and "Version packages" both reach master.
- The
release.yml
workflow runs again, however since there's a changeset file from PR B, it doesn't create the release (GitHub release nor npm publish) for the changes from PR A – the ones that came through in the "Version packages" PR. Instead it creates another "Version packages" PR, containing the bump + changeset removal from PR B. - The latest "Version packages" goes into the merge queue, and eventually reaches the
main
branch. - Again,
release.yml
runs and this time due to there being no new changeset files present, it performs the expected releases.
Although there are lots of steps here, I have simplified this a bit. We're in a situation where we don't get a release until for instance 5 or 6 "Version packages" PRs are merged during busy working hours.
Expected
In the list above, at step 8 when realease.yml
ran, we would expect it to create releases/publish for the bumped versions on main
branch, whilst also creating a new "Version packages" PR for the changesets present on main
.
Question
Is there a specific reason why the action doesn't publish and create PRs in the same run?
From checking out the code I can see that this is caused by the switch
statement in the primary index.ts
, where publish only occurs for this case:
Lines 65 to 68 in 04d574e
case !hasChangesets && hasPublishScript: { | |
core.info( | |
"No changesets found. Attempting to publish any unpublished packages to npm" | |
); |
And a PR is only created for this case:
Lines 119 to 121 in 04d574e
case hasChangesets: { | |
const octokit = setupOctokit(githubToken); | |
const { pullRequestNumber } = await runVersion({ |