-
Notifications
You must be signed in to change notification settings - Fork 154
85 lines (69 loc) · 3.33 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
- name: Create release
uses: actions/github-script@v7
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const { data } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const previousRelease = data.find((release) => !release.tag_name.startsWith("vscode-ruby-lsp") && release.tag_name !== "${{ github.ref_name }}");
const commitResponse = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: previousRelease.tag_name,
head: "${{ github.ref_name }}"
});
const pullRequests = [];
for (const commit of commitResponse.data.commits) {
const pullsResponse = await github.request(`GET /repos/shopify/ruby-lsp/commits/${commit.sha}/pulls`);
pullsResponse.data.forEach((pr) => {
if (!pullRequests.some((pull) => pull.url === pr.html_url)) {
pullRequests.push({
title: pr.title,
url: pr.html_url,
labels: pr.labels.map((label) => label.name)
});
}
});
}
const relevantPulls = pullRequests.filter((pull) => {
return pull.labels.some((label) => label === "server") &&
!pull.labels.some((label) => label === "dependencies") &&
!pull.labels.some((label) => label === "chore")
});
const breakingChanges = relevantPulls.filter((pull) => pull.labels.some((label) => label === "breaking-change"));
const bugFixes = relevantPulls.filter((pull) => pull.labels.some((label) => label === "bugfix"));
const enhancements = relevantPulls.filter((pull) => pull.labels.some((label) => label === "enhancement"));
const otherChanges = relevantPulls.filter((pull) => !pull.labels.some((label) => ["bugfix", "enhancement", "breaking-change"].includes(label)));
let content = `# ${{ github.ref_name }}\n`;
if (breakingChanges.length > 0) {
content += `## 🚧 Breaking Changes\n\n${breakingChanges.map((pull) => `- ${pull.title} (${pull.url})`).join("\n")}\n\n`;
}
if (enhancements.length > 0) {
content += `## ✨ Enhancements\n\n${enhancements.map((pull) => `- ${pull.title} (${pull.url})`).join("\n")}\n\n`;
}
if (bugFixes.length > 0) {
content += `## 🐛 Bug Fixes\n\n${bugFixes.map((pull) => `- ${pull.title} (${pull.url})`).join("\n")}\n\n`;
}
if (otherChanges.length > 0) {
content += `## 📦 Other Changes\n\n${otherChanges.map((pull) => `- ${pull.title} (${pull.url})`).join("\n")}\n\n`;
}
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ github.ref }}",
name: "${{ github.ref_name }}",
body: content
});