Skip to content

Commit

Permalink
Packages: Ensure only changed packages get published for WP releases (#…
Browse files Browse the repository at this point in the history
…55334)

* Packages: Ensure only changed packages get published for WP releases

* Clarify the reason for using fetch depth

* Iprove the wording for comments
  • Loading branch information
gziolo committed Nov 15, 2023
1 parent 70b30e9 commit 1dd3145
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish-npm-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
with:
path: publish
ref: wp/${{ github.event.inputs.wp_version }}
# We need to ensure that Lerna can read the commit created during the previous npm publishing.
# Lerna assumes that all packages need publishing if it can't access the necessary information.
fetch-depth: 999
token: ${{ secrets.GUTENBERG_TOKEN }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

Expand Down
22 changes: 6 additions & 16 deletions bin/plugin/commands/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,14 @@ async function checkoutNpmReleaseBranch( {
/*
* Create the release branch.
*
* Note that we are grabbing an arbitrary depth of commits
* during the fetch. When `lerna` attempts to determine if
* a package needs an update, it looks at `git` history,
* and if we have pruned that history it will pre-emptively
* publish when it doesn't need to.
*
* We could set a different arbitrary depth if this isn't
* long enough or if it's excessive. We could also try and
* find a way to more specifically fetch what we expect to
* change. For example, if we knew we'll be performing
* updates every two weeks, we might be conservative and
* use `--shallow-since=4.weeks.ago`.
*
* At the time of writing, a depth of 100 pulls in all
* `trunk` commits from within the past week.
* Note that we are grabbing an arbitrary depth of commits (999) during the fetch.
* When Lerna attempts to determine if a package needs an update, it looks at
* `git` history to find the commit created during the previous npm publishing.
* Lerna assumes that all packages need publishing if it can't access
* the necessary information.
*/
await SimpleGit( gitWorkingDirectoryPath )
.fetch( 'origin', npmReleaseBranch, [ '--depth=100' ] )
.fetch( 'origin', npmReleaseBranch, [ '--depth=999' ] )
.checkout( npmReleaseBranch );
log(
'>> The local npm release branch ' +
Expand Down

1 comment on commit 1dd3145

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1dd3145.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6876766151
📝 Reported issues:

Please sign in to comment.