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:
|
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:
|
case hasChangesets: { |
|
const octokit = setupOctokit(githubToken); |
|
const { pullRequestNumber } = await runVersion({ |
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
mainbranch, and the queue handles merging all the branches with the latestmain, 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
release.ymlworkflow to run, which has created a "Version packages" PR.release.ymlworkflow 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.mainbranch.release.ymlruns 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.ymlran, we would expect it to create releases/publish for the bumped versions onmainbranch, whilst also creating a new "Version packages" PR for the changesets present onmain.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
switchstatement in the primaryindex.ts, where publish only occurs for this case:action/src/index.ts
Lines 65 to 68 in 04d574e
And a PR is only created for this case:
action/src/index.ts
Lines 119 to 121 in 04d574e