Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Girazoki version bump job #420

Merged
merged 5 commits into from
Feb 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
run: rustup show

- name: Install zepter
run: cargo install --locked -f zepter
run: cargo install --locked -f zepter --version 1.1.0

- name: Run zepter
run: zepter run check
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create version bump ticket
on:
workflow_dispatch:
inputs:
from:
description: "Polkadot version to bump from (ex: v0.9.40)"
required: true
to:
description: "Polkadot version to bump to (ex: v0.9.42)"
required: true

jobs:
create_bump_ticket:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20.10.0
- name: Generate version bump issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd tools
yarn install
yarn --silent run print-version-bump-info -- --from ${{ github.event.inputs.from }} --to ${{ github.event.inputs.to }} | tee ../version-bump.md
- name: Create version bump issue
uses: peter-evans/create-issue-from-file@v3
with:
title: Update polkadot-sdk from ${{ github.event.inputs.from }} to ${{ github.event.inputs.to }}
content-filepath: ./version-bump.md
labels: |
automated issue
132 changes: 132 additions & 0 deletions tools/github/print-version-bump-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { Octokit } from "octokit";
import yargs from "yargs";
import { getCommitAndLabels } from "./github-utils";

async function printInfo(octokit: Octokit, previousVersion: string, nextVersion: string) {
const owners = {
"polkadot-sdk": "paritytech",
};
const prefixes = {
"polkadot-sdk": "polkadot-",
};
console.log(`# Description\n`);
console.log(`This ticket is automatically generated using\n`);
console.log("```");
console.log(`$ npm run print-version-bump-info -- --from ${previousVersion} --to ${nextVersion}`);
console.log("```");

const prInfoByLabels = {};
for (const repo of Object.keys(prefixes)) {
const previousTag = `${prefixes[repo]}${previousVersion}`;
const nextTag = `${prefixes[repo]}${nextVersion}`;
try {
const previousCommit = await octokit.rest.git.getCommit({
owner: owners[repo],
repo,
commit_sha: (
await octokit.rest.git.getTree({
owner: owners[repo],
repo,
tree_sha: previousTag,
})
).data.sha,
});
const nextCommit = await octokit.rest.git.getCommit({
owner: owners[repo],
repo,
commit_sha: (
await octokit.rest.git.getTree({
owner: owners[repo],
repo,
tree_sha: nextTag,
})
).data.sha,
});
console.log(
`\n## ${repo} (${previousCommit.data.author.date.slice(
0,
10
)} -> ${nextCommit.data.author.date.slice(0, 10)})\n`
);
const { commits, prByLabels } = await getCommitAndLabels(
octokit,
owners[repo],
repo,
previousTag,
nextTag
);
console.log(`https://github.com/${owners[repo]}/${repo}/compare/${previousTag}...${nextTag}`);
console.log("```");
console.log(` from: ${previousCommit.data.sha}`);
console.log(` to: ${nextCommit.data.sha}`);
console.log(` commits: ${commits.length}`);
console.log("```");

for (const label of Object.keys(prByLabels)) {
prInfoByLabels[label] = (prInfoByLabels[label] || []).concat(
prByLabels[label].map((pr) => {
return ` ${`(${owners[repo]}/${repo}#${pr.number}) ${pr.title}`}`;
})
);
}
} catch (e) {
console.trace(`Failing to query ${repo} [${previousTag}..${nextTag}]: ${e.toString()}`);
process.exit(1);
}
}

console.log(
`\n# Important commits by [label](https://paritytech.github.io/labels/doc_polkadot-sdk.html)\n`
);
const excludeRegs = [
/R0-/, // Silent Release
/I[0-9]-/, // Issue Category
/D[0-9]-/, // Difficulty
/C[0-9]-/, // Contribution
/A[0-9]-/, // Action
];
for (const labelName of Object.keys(prInfoByLabels).sort().reverse()) {
if (excludeRegs.some((f) => f.test(labelName))) {
continue;
}
console.log(`\n### ${labelName || "N/A"}\n`);
// Deduplicate PRs on same label
const deduplicatePrsOfLabel = prInfoByLabels[labelName].filter(function (elem, index, self) {
return index === self.indexOf(elem);
});
for (const prInfo of deduplicatePrsOfLabel) {
console.log(prInfo);
}
}

console.log(`\n## Review 'substrate-migrations' repo\n`);
console.log(`https://github.com/apopiak/substrate-migrations#frame-migrations`);
console.log(`\nThis repository contains a list of FRAME-related migrations which might be`);
console.log(`relevant to Moonbeam.`);
}

async function main() {
const argv = yargs(process.argv.slice(2))
.usage("Usage: npm run print-version-deps [args]")
.version("1.0.0")
.options({
from: {
type: "string",
describe: "commit-sha/tag of range start",
},
to: {
type: "string",
describe: "commit-sha/tag of range end",
},
})
.demandOption(["from", "to"])
.help().argv;

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN || undefined,
});

printInfo(octokit, argv.from, argv.to);
}

main();
3 changes: 2 additions & 1 deletion tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"scripts": {
"print-client-release-issue": "ts-node github/print-client-release-issue.ts",
"print-runtime-release-issue": "ts-node github/print-runtime-release-issue.ts"
"print-runtime-release-issue": "ts-node github/print-runtime-release-issue.ts",
"print-version-bump-info": "ts-node github/print-version-bump-info.ts"
}
}
Loading