Skip to content

Instantly share code, notes, and snippets.

@skarllot
Last active December 8, 2024 21:07
Show Gist options
  • Save skarllot/8fcda44a9fd2d356c15bb63fec2246d7 to your computer and use it in GitHub Desktop.
Save skarllot/8fcda44a9fd2d356c15bb63fec2246d7 to your computer and use it in GitHub Desktop.
Remove duplicates from GitHub release notes
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"string content = @\"* build(deps): update dotnet monorepo by @renovate in https://github.com/skarllot/Expressions/pull/347\n",
"* ci: Configure versioning per package by @skarllot in https://github.com/skarllot/Expressions/pull/350\n",
"* ci(github-action): update github/codeql-action action to v3.26.13 by @renovate in https://github.com/skarllot/Expressions/pull/348\n",
"* build(deps): update dependency swashbuckle.aspnetcore to 6.9.0 by @renovate in https://github.com/skarllot/Expressions/pull/349\n",
"* build(deps): update dependency marten to 7.30.2 by @renovate in https://github.com/skarllot/Expressions/pull/351\n",
"* build(deps): update dependency npgsql.entityframeworkcore.postgresql to 8.0.10 by @renovate in https://github.com/skarllot/Expressions/pull/352\n",
"* chore: Setup release versioning by @skarllot in https://github.com/skarllot/Expressions/pull/371\n",
"* ci(github-action): update actions/dependency-review-action action to v4.4.0 by @renovate in https://github.com/skarllot/Expressions/pull/356\n",
"* ci(github-action): update actions/setup-dotnet action to v4.1.0 by @renovate in https://github.com/skarllot/Expressions/pull/357\n",
"* ci(github-action): update actions/cache action to v4.1.2 by @renovate in https://github.com/skarllot/Expressions/pull/358\n",
"* ci(github-action): update github/codeql-action action to v3.27.4 by @renovate in https://github.com/skarllot/Expressions/pull/359\n",
"* ci(github-action): update actions/checkout action to v4.2.2 by @renovate in https://github.com/skarllot/Expressions/pull/360\n",
"* ci(github-action): update actions/setup-node action to v4.1.0 by @renovate in https://github.com/skarllot/Expressions/pull/362\n",
"* build(deps-dev): update dependency vitepress to ^1.5.0 by @renovate in https://github.com/skarllot/Expressions/pull/364\n",
"* build(deps): update dotnet monorepo by @renovate in https://github.com/skarllot/Expressions/pull/367\n",
"* build(deps): update dotnet monorepo by @renovate in https://github.com/skarllot/Expressions/pull/380\n",
"* ci(github-action): update step-security/harden-runner action to v2.10.2 by @renovate in https://github.com/skarllot/Expressions/pull/375\n",
"* ci(github-action): update codecov/codecov-action action to v5 by @renovate in https://github.com/skarllot/Expressions/pull/376\n",
"* ci(github-action): update github/codeql-action action to v3.27.5 by @renovate in https://github.com/skarllot/Expressions/pull/378\n",
"* build(deps): update dependency fluentassertions to 6.12.2 by @renovate in https://github.com/skarllot/Expressions/pull/366\n",
"* build(deps): update dpage/pgadmin4 docker digest to 561c1f8 by @renovate in https://github.com/skarllot/Expressions/pull/368\n",
"* ci(github-action): update actions/dependency-review-action action to v4.5.0 by @renovate in https://github.com/skarllot/Expressions/pull/379\n",
"* build(deps): update dependency microsoft.extensions.dependencyinjection to 6.0.2 by @renovate in https://github.com/skarllot/Expressions/pull/369\n",
"* build(deps): update dependency microsoft.net.test.sdk to 17.12.0 by @renovate in https://github.com/skarllot/Expressions/pull/377\n",
"* build(deps): update dependency marten to 7.33.2 by @renovate in https://github.com/skarllot/Expressions/pull/353\n",
"* build(deps): update nerdbank.gitversioning to 3.6.146 by @renovate in https://github.com/skarllot/Expressions/pull/361\n",
"* build(deps): update dependency nsubstitute to 5.3.0 by @renovate in https://github.com/skarllot/Expressions/pull/363\n",
"* build(deps): update dependency testcontainers.postgresql to v4 by @renovate in https://github.com/skarllot/Expressions/pull/365\n",
"* build(deps): update entity framework core by @renovate in https://github.com/skarllot/Expressions/pull/370\n",
"* build(deps): update dependency portable.system.datetimeonly to 8.0.2 by @renovate in https://github.com/skarllot/Expressions/pull/372\n",
"* build(deps): update dependency swashbuckle.aspnetcore to v7 by @renovate in https://github.com/skarllot/Expressions/pull/373\n",
"* build(deps): update npgsql by @renovate in https://github.com/skarllot/Expressions/pull/374\n",
"* ci(github-action): update github/codeql-action action to v3.27.6 by @renovate in https://github.com/skarllot/Expressions/pull/381\";"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"using System.Text.RegularExpressions;\n",
"\n",
"var prPattern = @\"https://github[.]com/[A-z0-9\\-]+/[A-z0-9\\-]+/pull/\";\n",
"\n",
"content = Regex.Replace(content, prPattern, \"#\");"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"using System.Text.RegularExpressions;\n",
"\n",
"var keyPattern = @\": (update|bump|pin)( dependency)? (([A-z0-9\\-/.:]+|[a-z ]+))( docker digest)?( action)?( from [^ ]+)?( to [^ ]+)?( in [^ ]+)? by @\";\n",
"\n",
"var values = content.Split(\"\\n\").Select(x => new {\n",
" Key = Regex.Match(x, keyPattern).Groups[3].Value,\n",
" Value = x,\n",
" Author = Regex.Match(x, @\"@(\\w+)\").Groups[1].Value,\n",
" PR = int.Parse(Regex.Match(x, @\"in #(\\d+)\").Groups[1].Value) });\n",
"\n",
"//display($\"Unknown keys: {values.Count(x => string.IsNullOrWhiteSpace(x.Key))}\");\n",
"//display(values.GroupBy(x => x.Key).Select(x => new { Key = x.Key, Count = x.Count(), Values = x.ToList() }));\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"data": {
"text/plain": [
"* ci: Configure versioning per package by @skarllot in #350\n",
"* chore: Setup release versioning by @skarllot in #371\n",
"\n",
"## πŸ“’ Breaking Changes\n",
"## πŸ›‘οΈ Security Fixes\n",
"## πŸš€ New Features\n",
"## 🐞 Bug fixes\n",
"## πŸ”§ Maintenance\n",
"## πŸ§ͺ Testing & CI/CD\n",
"## πŸ“– Docs updates\n",
"\n",
"## πŸ“¦ Dependency Updates\n",
"* build(deps): update dependency npgsql.entityframeworkcore.postgresql to 8.0.10 by @renovate in #352\n",
"* build(deps): update dependency marten to 7.33.2 by @renovate in #353\n",
"* build(deps): update nerdbank.gitversioning to 3.6.146 by @renovate in #361\n",
"* build(deps): update dependency nsubstitute to 5.3.0 by @renovate in #363\n",
"* build(deps-dev): update dependency vitepress to ^1.5.0 by @renovate in #364\n",
"* build(deps): update dependency testcontainers.postgresql to v4 by @renovate in #365\n",
"* build(deps): update dependency fluentassertions to 6.12.2 by @renovate in #366\n",
"* build(deps): update dpage/pgadmin4 docker digest to 561c1f8 by @renovate in #368\n",
"* build(deps): update dependency microsoft.extensions.dependencyinjection to 6.0.2 by @renovate in #369\n",
"* build(deps): update entity framework core by @renovate in #370\n",
"* build(deps): update dependency portable.system.datetimeonly to 8.0.2 by @renovate in #372\n",
"* build(deps): update dependency swashbuckle.aspnetcore to v7 by @renovate in #373\n",
"* build(deps): update npgsql by @renovate in #374\n",
"* build(deps): update dependency microsoft.net.test.sdk to 17.12.0 by @renovate in #377\n",
"* build(deps): update dotnet monorepo by @renovate in #380"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"var dependencyBots = new List<string> { \"renovate\", \"dependabot\" };\n",
"var noKeys = values\n",
" .Where(x => string.IsNullOrEmpty(x.Key) || !dependencyBots.Contains(x.Author))\n",
" .Select(x => new { Value = x.Value, PR = x.PR })\n",
" .OrderBy(x => x.PR)\n",
" .Select(x => x.Value);\n",
"var result = values\n",
" .Where(x => !string.IsNullOrEmpty(x.Key) && dependencyBots.Contains(x.Author))\n",
" .Where(x => !x.Value.Contains(\"github-action\", StringComparison.OrdinalIgnoreCase))\n",
" .GroupBy(x => x.Key)\n",
" .Select(x => new { Value = x.MaxBy(y => y.PR).Value, PR = x.MaxBy(y => y.PR).PR })\n",
" .OrderBy(x => x.PR)\n",
" .Select(x => x.Value);\n",
"\n",
"display(\n",
" $\"\"\"\n",
" {string.Join(\"\\n\", noKeys)}\n",
" \n",
" ## πŸ“’ Breaking Changes\n",
" ## πŸ›‘οΈ Security Fixes\n",
" ## πŸš€ New Features\n",
" ## 🐞 Bug fixes\n",
" ## πŸ”§ Maintenance\n",
" ## πŸ§ͺ Testing & CI/CD\n",
" ## πŸ“– Docs updates\n",
"\n",
" ## πŸ“¦ Dependency Updates\n",
" {string.Join(\"\\n\", result)}\n",
" \"\"\"\n",
");"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"name": "C#"
},
"polyglot_notebook": {
"kernelInfo": {
"defaultKernelName": "csharp",
"items": [
{
"aliases": [],
"name": "csharp"
}
]
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment