From 52d16358d022750c80966daec5b01a645563f906 Mon Sep 17 00:00:00 2001 From: girazoki Date: Mon, 19 Feb 2024 10:23:22 +0100 Subject: [PATCH 1/5] create version bump ticket --- .github/workflows/version-bump.yml | 35 +++++++ tools/github/print-version-bump-info.ts | 132 ++++++++++++++++++++++++ tools/package.json | 3 +- 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/version-bump.yml create mode 100644 tools/github/print-version-bump-info.ts diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 000000000..509f84b85 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -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 substrate/polkadot/cumulus from ${{ github.event.inputs.from }} to ${{ github.event.inputs.to }} + content-filepath: ./version-bump.md + labels: | + automated issue \ No newline at end of file diff --git a/tools/github/print-version-bump-info.ts b/tools/github/print-version-bump-info.ts new file mode 100644 index 000000000..734fc7023 --- /dev/null +++ b/tools/github/print-version-bump-info.ts @@ -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(); \ No newline at end of file diff --git a/tools/package.json b/tools/package.json index 0f15174e4..7ad955271 100644 --- a/tools/package.json +++ b/tools/package.json @@ -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" } } From a5fdc3dd72148dca6c8ec9ee2fef13798d2bedd9 Mon Sep 17 00:00:00 2001 From: girazoki Date: Mon, 19 Feb 2024 10:23:54 +0100 Subject: [PATCH 2/5] trigger job --- .github/workflows/version-bump.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 509f84b85..22afb6549 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -8,6 +8,7 @@ on: to: description: "Polkadot version to bump to (ex: v0.9.42)" required: true + push jobs: create_bump_ticket: From 4d9e15216353663bb23cc49df732e6e529a58c5b Mon Sep 17 00:00:00 2001 From: girazoki Date: Mon, 19 Feb 2024 10:24:20 +0100 Subject: [PATCH 3/5] remove trigger --- .github/workflows/version-bump.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 22afb6549..509f84b85 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -8,7 +8,6 @@ on: to: description: "Polkadot version to bump to (ex: v0.9.42)" required: true - push jobs: create_bump_ticket: From 28a87caa7f7f04b028b31c4f7a63f5e46f1a157b Mon Sep 17 00:00:00 2001 From: girazoki Date: Mon, 19 Feb 2024 11:04:15 +0100 Subject: [PATCH 4/5] install specific zepter version --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de33f6541..47211e8e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 From c6eb89648b765fe0e515b4658a3f0c6eb946669b Mon Sep 17 00:00:00 2001 From: girazoki Date: Mon, 19 Feb 2024 12:24:53 +0100 Subject: [PATCH 5/5] pr comments --- .github/workflows/version-bump.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 509f84b85..874eaabdf 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -29,7 +29,7 @@ jobs: - name: Create version bump issue uses: peter-evans/create-issue-from-file@v3 with: - title: Update substrate/polkadot/cumulus from ${{ github.event.inputs.from }} to ${{ github.event.inputs.to }} + title: Update polkadot-sdk from ${{ github.event.inputs.from }} to ${{ github.event.inputs.to }} content-filepath: ./version-bump.md labels: | automated issue \ No newline at end of file