Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/reusable-milestone-merged-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,18 @@ jobs:
// Pick and derive from a single snapshot, so that concurrent runs
// that both find no open milestone compute the same next title.
const all = versioned( await fetchMilestones( 'all' ) );
const open = all.filter( ( entry ) => entry.milestone.state === 'open' );
const closed = all.filter( ( entry ) => entry.milestone.state === 'closed' );
const released = closed.length > 0 ? closed[ closed.length - 1 ] : null;

// Relative to the latest release, skip stale open milestones and
// ones for a future major (e.g. `4.0.0` right after `3.0.0`
// shipped), which are reserved for breaking changes.
const open = all
.filter( ( entry ) => entry.milestone.state === 'open' )
.filter( ( entry ) => ! released || (
compare( entry, released ) > 0 &&
entry.version.parts[0] === released.version.parts[0]
) );
if ( open.length > 0 ) {
milestone = open[0].milestone;
core.info( `Using lowest open milestone ${ milestone.title }.` );
Expand All @@ -77,7 +88,7 @@ jobs:
return;
}

const latest = all[ all.length - 1 ].version;
const latest = ( released ?? all[ all.length - 1 ] ).version;
const [ major, minor, patch ] = latest.parts;
const title = `${ latest.prefix }${ major }.${ minor }.${ patch + 1 }`;

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ For example, if a repository releases `v2.2.6` or `v2.3.0`, the branch-alias sta

When a pull request is merged into `main` or `master` and has no milestone yet, this workflow adds it to the next release milestone:

1. If there are open milestones with version titles (e.g. `2.12.1`), it uses the lowest one
2. Otherwise it creates a new milestone one patch version above the highest existing one (e.g. `2.12.0` → `2.12.1`)
1. If there are open milestones with version titles (e.g. `2.12.1`) above the latest closed (released) one and within the same major version, it uses the lowest one
2. Otherwise it creates a new milestone one patch version above the latest released one (e.g. `3.0.0` → `3.0.1`)
3. If the repository has no versioned milestones at all, it does nothing

Open milestones for a future major version (e.g. `4.0.0` right after `3.0.0` was released) are never picked automatically, so breaking changes have to be assigned to them by hand.

## Installing

There's nothing to install, this package cannot be used directly.
Expand Down
Loading