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
72 changes: 72 additions & 0 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Milestone on merge
# Assigns a pull request merged into the default branch to the milestone of the
# next release: the open vX.Y milestone with the lowest version above the latest
# stable release. With v1.8.2 released and v1.8, v2.0, v2.1 and v3.0 open, that
# is v2.0; once v2.0.0 is released it becomes v2.1. No list is maintained here.
on:
pull_request_target:
types: [closed]

permissions:
contents: read
pull-requests: write

jobs:
milestone:
if: >-
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == github.event.repository.default_branch
runs-on: ubuntu-slim
timeout-minutes: 5
steps:
# No checkout: only the API is used.
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Suggestion: Use the repository's existing github-script pin

This workflow pins actions/github-script to the v8.0.0 commit, while the existing workflow in .github/workflows/docker.yml uses the v9.0.0 commit. The pull request description says this action is pinned to the same SHA as existing workflows, and the repository's dependency bump history updates the shared action version together. Keeping a second pin creates a divergent convention that future Dependabot or maintenance updates must handle separately.

Suggested change
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0

source: glm-5.3-flash (phase1-reviewer: general)

with:
script: |
const pr = context.payload.pull_request;
const { owner, repo } = context.repo;
const releaseTag = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
const milestoneTitle = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
const parse = (text, pattern) => {
const m = pattern.exec(text);
return m && m[0] === text &&
{ major: +m[1], minor: +m[2], patch: +(m[3] ?? 0) };
};
const compare = (a, b) =>
a.major - b.major || a.minor - b.minor || a.patch - b.patch;

// Latest non-prerelease, non-draft release.
const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo });
const stable = parse(release.tag_name, releaseTag);
if (!stable) {
core.warning(`Latest release tag ${release.tag_name} is not vX.Y.Z; milestone of #${pr.number} left unchanged.`);
return;
}

// Next line: lowest open milestone whose major.minor is above the stable
// release, so the stable line's own milestones (v1.8, v1.8.3) are skipped.
const open = await github.paginate(github.rest.issues.listMilestones, {
owner, repo, state: 'open', per_page: 100,
});
const candidates = open
.map((m) => ({ milestone: m, version: parse(m.title, milestoneTitle) }))
.filter(({ version }) => version &&
compare({ ...version, patch: 0 }, { ...stable, patch: 0 }) > 0)
.sort((a, b) => compare(a.version, b.version));
if (candidates.length === 0) {
core.warning(`No open milestone above ${release.tag_name}; milestone of #${pr.number} left unchanged.`);
return;
}
const { milestone } = candidates[0];

if (pr.milestone?.number === milestone.number) {
core.info(`#${pr.number} is already in ${milestone.title}.`);
return;
}
if (pr.milestone) {
core.notice(`#${pr.number} moves from ${pr.milestone.title} to ${milestone.title}, the next release after ${release.tag_name}.`);
}
await github.rest.issues.update({
owner, repo, issue_number: pr.number, milestone: milestone.number,
});
core.info(`#${pr.number} assigned to ${milestone.title} (latest stable release ${release.tag_name}).`);
7 changes: 7 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ an explicit Platform support decision rather than automatic maintenance promises
Release tags remain `vX.Y.Z`; prereleases use `vX.Y.Z-dev.N`. The skill evaluates
SemVer from compatibility, not branch names or `feat`/`fix` labels.

A pull request merged into `dev` is assigned to the next release's milestone
(`.github/workflows/milestone.yml`): the open `vX.Y` milestone with the lowest
version above the latest stable release, so with `v1.8.2` released it lands in
`v2.0`, and in `v2.1` once `v2.0.0` is released. Keep the next release's
milestone open; with none above the latest stable release the pull request's
milestone is left unchanged.

Full-release promotion and stable-to-dev synchronization should preserve
ancestry. Master currently has protection rules that must be reconciled with
that merge strategy by maintainers before a release. The skill must report any
Expand Down
Loading