-
Notifications
You must be signed in to change notification settings - Fork 253
117 lines (94 loc) · 4.4 KB
/
release_gem.yml
File metadata and controls
117 lines (94 loc) · 4.4 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Release gem on RubyGems.org and create GitHub release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
release_gem:
name: Release gem on RubyGems.org
if: github.repository == 'Shopify/ruby-lsp'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
environment: release
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
with:
bundler-cache: true
- name: Release gem on RubyGems.org
uses: rubygems/release-gem@e9a6361a0b14562539327c2a02373edc56dd3169 # v1.1.4
release_github:
name: Create GitHub release
if: github.repository == 'Shopify/ruby-lsp'
needs: release_gem
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create release
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
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),
author: pr.user.login
});
}
});
}
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}) by @${pull.author}`).join("\n")}\n\n`;
}
if (enhancements.length > 0) {
content += `## ✨ Enhancements\n\n${enhancements.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`;
}
if (bugFixes.length > 0) {
content += `## 🐛 Bug Fixes\n\n${bugFixes.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).join("\n")}\n\n`;
}
if (otherChanges.length > 0) {
content += `## 📦 Other Changes\n\n${otherChanges.map((pull) => `- ${pull.title} (${pull.url}) by @${pull.author}`).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
});