8
n8n 中文网amn8n.com

自动生成发布说明

中级

这是一个DevOps领域的自动化工作流,包含 10 个节点。主要使用 Set, Code, FormTrigger, HttpRequest 等节点。 自动生成GitHub发布说明并通过Slack通知

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CK1X6HPPuntaDwNl",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa",
    "templateCredsSetupCompleted": true
  },
  "name": "自动生成发布说明",
  "tags": [],
  "nodes": [
    {
      "id": "74c1115a-e28b-478e-b4d5-d3c7e890b39c",
      "name": "配置",
      "type": "n8n-nodes-base.set",
      "position": [
        200,
        40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8b87d9c7-3a18-42a9-9ec1-8568fea2908a",
              "name": "repoOwner",
              "type": "string",
              "value": "={{ $json['Repository Owner'] }}"
            },
            {
              "id": "5cac0fee-0aa9-4a4f-a610-8fc3b8682039",
              "name": "repoName",
              "type": "string",
              "value": "={{ $json['Repository Name'] }}"
            },
            {
              "id": "ce2d2b21-55c8-4913-863f-c686e0a51610",
              "name": "defaultBranch",
              "type": "string",
              "value": "={{ $json['Branch Name'] }}"
            },
            {
              "id": "3445fa18-848c-4df5-b5d0-458f978d7cf1",
              "name": "=labelMap",
              "type": "string",
              "value": "{ \"Feature\": \"🚀 Features\", \"bug\": \"🐞 Bug Fixes\", \"performance\": \"⚡ Performance\", \"sdk\": \"📦 SDK / Dependency\" }"
            },
            {
              "id": "29753009-bf1f-40d0-adb9-2ae8135c2eed",
              "name": "=qaChecklist",
              "type": "string",
              "value": "[ \"[ ] App boots successfully\", \"[ ] No crash on startup\", \"[ ] All features tested\", \"[ ] No broken UI on devices\" ]"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dc575c60-f1ad-439f-8176-0729c109f631",
      "name": "获取最新 Git 标签",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        420,
        40
      ],
      "parameters": {
        "url": "=https://api.github.com/repos/{{$json[\"repoOwner\"]}}/{{$json[\"repoName\"]}}/tags",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "githubApi"
      },
      "credentials": {
        "githubApi": {
          "id": "sWK5QVSgNgKCkpaF",
          "name": "GitHub account"
        },
        "httpHeaderAuth": {
          "id": "Q6oCLdEppyzR0Uga",
          "name": "Header Auth account 3"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a45ac6c8-8f50-49c8-97cd-24e57d3b9c24",
      "name": "获取最新标签的提交日期",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        40
      ],
      "parameters": {
        "url": "={{$json[\"commit\"][\"url\"]}}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "51399899-3a7b-44d3-9067-64e474d0a00a",
      "name": "获取自上次标签以来的所有合并 PR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        860,
        40
      ],
      "parameters": {
        "url": "=https://api.github.com/search/issues?q=is:pr+is:merged+repo:{{ $('Config').first().json.repoOwner }}/{{ $('Config').first().json.repoName }}+base:{{ $('Config').first().json.defaultBranch }}+merged:>={{ $json.commit.author.date }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "ed1609f1-f1c0-4c15-adb5-b116af6e0a44",
      "name": "已调整:分组 PR 并生成发布说明",
      "type": "n8n-nodes-base.code",
      "position": [
        1080,
        40
      ],
      "parameters": {
        "jsCode": "// SAFELY access config node data\nconst configNode = $('Config').first();\nif (!configNode) {\n  throw new Error(\"Missing 'Config' node or it's not accessible.\");\n}\n\nconst labelMap =  configNode.labelMap|| {};\nconst qaChecklist = configNode.qaChecklist || [];\n\nconsole.log(\"Your message\", labelMap);\nconsole.log(\"Your message\", qaChecklist);\n\n// Access PR list from previous node\nconst prNode = $('Fetch All Merged PRs Since Last Tag').first(); // <-- Replace with your actual PR-fetch node name\nif (!prNode || !prNode.json || !Array.isArray(prNode.json.items)) {\n  throw new Error(\"Pull request data not found or improperly formatted.\");\n}\n\nconst prItems = prNode.json.items;\n\n/** @type {Record<string, string[]>} */\nconst grouped = {};\n\n// Loop through each PR\nfor (const pr of prItems) {\n  const labels = pr.labels?.map(l => l.name) || [];\n  const matchedKey = labels.find(l => labelMap[l]);\n  const groupTitle = matchedKey ? labelMap[matchedKey] : \"📋 Others\";\n\n  if (!grouped[groupTitle]) {\n    grouped[groupTitle] = [];\n  }\n\n  grouped[groupTitle].push(`- ${pr.title} (#${pr.number})`);\n}\n\n// Build Markdown content\nlet markdown = `## 📝 Release Notes\\n`;\n\nfor (const group in grouped) {\n  markdown += `\\n### ${group}\\n`;\n  markdown += grouped[group].join(\"\\n\") + \"\\n\";\n}\n\nmarkdown += `\\n## ✅ QA Checklist\\n`;\nmarkdown += qaChecklist.map(item => `[ ] ${item}`).join(\"\\n\");\n\nreturn [\n  {\n    json: {\n      release_notes: markdown,\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "589e2cf2-e5f5-4411-a0ba-a4f705d242f9",
      "name": "Github 预发布",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1300,
        40
      ],
      "parameters": {
        "url": "=https://api.github.com/repos/{{ $('Config').first().json.repoOwner }}/{{ $('Config').first().json.repoName }}/releases",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "tag_name",
              "value": "={{ $('Get Latest Git Tag').first().json.name }}"
            },
            {
              "name": "name",
              "value": "={{ $('Get Latest Git Tag').first().json.name }}"
            },
            {
              "name": "body",
              "value": "={{ $json.release_notes }}"
            },
            {
              "name": "draft",
              "value": "={{ true }}"
            },
            {
              "name": "prerelease",
              "value": "={{ false }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "Q6oCLdEppyzR0Uga",
          "name": "Header Auth account 3"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2190c525-95c9-49e8-84de-e13df0d826e5",
      "name": "发送消息到 slack",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1520,
        40
      ],
      "parameters": {
        "url": "",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $('Adjusted: Group PRs & Generate Release Notes').item.json.release_notes }} {{ $json.html_url }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6c385b76-cc8e-4cbd-b086-0e2c7e9f42bc",
      "name": "GitHub 发布输入表单",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -20,
        40
      ],
      "webhookId": "80253212-d5c6-4542-9dba-b9ec3f7cc48d",
      "parameters": {
        "options": {},
        "formTitle": "GitHub Release Input Form",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Repository Name",
              "placeholder": "Enter name of the repository",
              "requiredField": true
            },
            {
              "fieldLabel": "Repository Owner",
              "placeholder": "Enter username of github",
              "requiredField": true
            },
            {
              "fieldLabel": "Branch Name",
              "placeholder": "Enter branch name ",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bd0ad833-757e-4619-b31a-7abfef910fe7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -60
      ],
      "parameters": {
        "width": 1860,
        "height": 360,
        "content": "## 为任何 GitHub 仓库自动生成发布说明 → Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "fa9609ed-9ef4-43b7-b1e5-1b2245cdc657",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        320
      ],
      "parameters": {
        "width": 1880,
        "height": 1260,
        "content": "#🚀 GitHub 自动化发布工作流 (n8n)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e0e3b36d-59a8-4ec1-a1e5-5a19fb5063ed",
  "connections": {
    "Config": {
      "main": [
        [
          {
            "node": "Get Latest Git Tag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Latest Git Tag": {
      "main": [
        [
          {
            "node": "Get Commit Date of Latest Tag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Github Pre Release": {
      "main": [
        [
          {
            "node": " Send message to slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GitHub Release Input Form": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Commit Date of Latest Tag": {
      "main": [
        [
          {
            "node": "Fetch All Merged PRs Since Last Tag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Merged PRs Since Last Tag": {
      "main": [
        [
          {
            "node": "Adjusted: Group PRs & Generate Release Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Adjusted: Group PRs & Generate Release Notes": {
      "main": [
        [
          {
            "node": "Github Pre Release",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 开发运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类1
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流