-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
339bd8b
commit b20a0b5
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Draft release notes on tag | ||
on: | ||
push | ||
|
||
jobs: | ||
draft_release_notes2: | ||
name: Draft release notes | ||
#if: github.event.ref_type == 'tag' && github.event.master_branch == 'master' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get milestone title | ||
id: milestoneTitle | ||
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # 6.4.1 | ||
with: | ||
result-encoding: string | ||
script: | | ||
// Get the milestone title ("X.Y.Z") from tag name ("vX.Y.Z") | ||
//const milestoneTitle = '${{github.event.ref}}'.startsWith('v') ? | ||
// '${{github.event.ref}}'.substring(1) : | ||
// '${{github.event.ref}}' | ||
const milestoneTitle = '1.16.0' | ||
// Look for the milestone | ||
const milestone = (await github.paginate('GET /repos/{owner}/{repo}/milestones', { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state: 'all' | ||
})).find(m => m.title == milestoneTitle) | ||
if (!milestone) { | ||
core.setFailed('Failed to find milestone: ${milestoneTitle}') | ||
return | ||
} | ||
// Get pull requests of the milestone | ||
const pullRequests = (await github.paginate('/repos/{owner}/{repo}/issues', { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
milestone: milestone.number, | ||
state: 'closed' | ||
})) | ||
.filter(i => i.pull_request && i.pull_request.merged_at) // Skip closed but not merged | ||
.filter(p => !p.labels.find(label => label.name == 'tag: no release notes')) // Skip excluded | ||
console.log(pullRequests) | ||
var prByComponents = new Map() | ||
var prByInstrumentations = new Map() | ||
for (let pullRequest of pullRequests) { | ||
for (let label of pullRequest.labels) { | ||
const index = label.name.indexOf(':') | ||
if (index == -1) { | ||
core.notice('Unsupported label: ${label.name}') | ||
continue | ||
} | ||
const labelKey = label.name.substring(0, index) | ||
const labelValue = label.name.slice(index + 1) | ||
var map = null | ||
if (labelKey == 'comp') { | ||
map = prByComponents | ||
} else if (labelKey == 'inst') { | ||
map = prByInstrumentations | ||
} | ||
if (map) { | ||
var prs = map.get(label.description) | ||
if (!prs) { | ||
prs = new Array() | ||
map.set(label.description, prs) | ||
} | ||
prs.push(pullRequest) | ||
} | ||
} | ||
} | ||
console.log("components: ") | ||
console.log(prByComponents) | ||
console.log("instrumentations: ") | ||
console.log(prByInstrumentations) | ||