Files
grafana/scripts/cli/tasks/cherrypick.ts
T
gotjosh bc94f85dee Improvement: Grafana release process minor improvements (#17661)
* Don't display changelog category title when no items

The output of the changelog is meant to be copy/pasted with ease. When a
changelog category does not contain items is better to not display title
at all thus avoiding having the manually modify the output as we include
it in the steps of the process.

* Introduce a CLI task to close milestones whilst doing a Grafana release

As part of a Grafana release, we need to eventually close the GitHub
milestone to indicate is done and remove all the cherry-pick labels from
issues/prs within the milestone to avoid our cherry-pick CLI command to
pick them up on the next release.

* Abstract the GitHub client into a module

* Introduce `GitHubClient` to all CLI tasks
2019-06-24 16:00:01 +01:00

48 lines
1.6 KiB
TypeScript

import { Task, TaskRunner } from './task';
import GithubClient from '../utils/githubClient';
interface CherryPickOptions {}
const cherryPickRunner: TaskRunner<CherryPickOptions> = async () => {
const githubClient = new GithubClient();
const client = githubClient.client;
const res = await client.get('/issues', {
params: {
state: 'closed',
labels: 'cherry-pick needed',
},
});
// sort by closed date ASC
res.data.sort(function(a, b) {
return new Date(a.closed_at).getTime() - new Date(b.closed_at).getTime();
});
let commands = '';
console.log('--------------------------------------------------------------------');
console.log('Printing PRs with cherry-pick-needed, in ASC merge date order');
console.log('--------------------------------------------------------------------');
for (const item of res.data) {
if (!item.milestone) {
console.log(item.number + ' missing milestone!');
continue;
}
const issueDetails = await client.get(item.pull_request.url);
console.log(`* ${item.title}, (#${item.number}), merge-sha: ${issueDetails.data.merge_commit_sha}`);
commands += `git cherry-pick -x ${issueDetails.data.merge_commit_sha}\n`;
}
console.log('--------------------------------------------------------------------');
console.log('Commands (in order of how they should be executed)');
console.log('--------------------------------------------------------------------');
console.log(commands);
};
export const cherryPickTask = new Task<CherryPickOptions>();
cherryPickTask.setName('Cherry pick task');
cherryPickTask.setRunner(cherryPickRunner);