-
Notifications
You must be signed in to change notification settings - Fork 70
177 lines (155 loc) · 5.89 KB
/
new-upstream-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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Notify new upstream release
on:
workflow_dispatch:
schedule:
- cron: "0 0/12 * * *"
jobs:
notify-new-release:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm init --yes
- run: npm install semver
- name: Check for new release branch
id: new-release
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const semver = require('semver');
let nextRelease = undefined;
try {
const { data: latestRelease } = await github.rest.repos.getLatestRelease({
owner: 'microsoft',
repo: 'vscode'
});
const releaseTag = latestRelease.tag_name;
const nextReleaseTag = semver.inc(releaseTag, 'minor');
nextRelease = `release/${semver.major(nextReleaseTag)}.${semver.minor(nextReleaseTag)}`;
console.log(nextRelease);
} catch (e) {
console.error(e);
return false;
}
let upstreamReleaseBranch = undefined;
try {
const response = await github.rest.repos.getBranch({
owner: 'microsoft',
repo: 'vscode',
branch: nextRelease
});
upstreamReleaseBranch = response.data;
console.log(upstreamReleaseBranch);
} catch (e) {
console.error(e);
return false;
}
let releaseBranch = undefined;
try {
const response = await github.rest.repos.getBranch({
owner: 'gitpod-io',
repo: 'openvscode-server',
branch: nextRelease
});
releaseBranch = response.data;
} catch (e) {
console.log(e);
}
// If we already created the release branch in openvscode-server, don't create a notification
return releaseBranch ? false : true;
- name: Slack Notification
if: steps.new-release.outputs.result == 'true'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "#FDD20A"
SLACK_TITLE: New vscode release branch created
SLACK_MESSAGE: |
Start preparing for a new release :exclamation:
Trigger GHA https://github.com/gitpod-io/gitpod/actions/workflows/code-build.yaml after sync upstream
notify-recovery-release:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm init --yes
- run: npm install semver
- name: Check for recovery release commits
id: new-recovery-release
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const semver = require('semver');
let currentRelease = undefined;
try {
const { data: latestRelease } = await github.rest.repos.getLatestRelease({
owner: 'microsoft',
repo: 'vscode'
});
const releaseTag = latestRelease.tag_name;
currentRelease = `release/${semver.major(releaseTag)}.${semver.minor(releaseTag)}`;
console.log(currentRelease);
} catch (e) {
console.error(e);
return false;
}
let lastSyncCommit = undefined;
try {
// Look for the last sync commit from upstream. For now just query it once
// as it's unlikely that we are more than 100 commits ahead of upstream
const response = await github.rest.repos.listCommits({
owner: 'gitpod-io',
repo: 'openvscode-server',
sha: currentRelease,
per_page: 100,
page: 1
});
const commitsArr = response.data;
const initialCommitIdx = commitsArr.findIndex(commitData => {
return commitData.commit.message === 'code web server initial commit';
});
lastSyncCommit = initialCommitIdx >= 0 ? commitsArr[initialCommitIdx + 1] : undefined;
console.log(lastSyncCommit.html_url);
} catch (e) {
console.error(e);
return false;
}
if(!lastSyncCommit) {
return false;
}
let newCommits = [];
try {
const response = await github.rest.repos.listCommits({
owner: 'microsoft',
repo: 'vscode',
sha: currentRelease,
per_page: 100,
page: 1
});
const commitsArr = response.data;
const lastSyncCommitIdx = commitsArr.findIndex(commitData => {
return commitData.sha === lastSyncCommit.sha;
});
if (lastSyncCommitIdx > 0) {
newCommits = commitsArr.slice(0, lastSyncCommitIdx).map(commitData => commitData.html_url);
console.log(newCommits);
}
} catch (e) {
console.log(e);
return false;
}
return newCommits.length > 0 ? true : false;
- name: Slack Notification
if: steps.new-recovery-release.outputs.result == 'true'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "#FDD20A"
SLACK_TITLE: New commits on latest release branch
SLACK_MESSAGE: |
Start preparing for a new recovery release :exclamation:
Trigger GHA https://github.com/gitpod-io/gitpod/actions/workflows/code-build.yaml after sync upstream