19
19
20
20
outputs :
21
21
dotnet-core-updated-sha : ${{ steps.check-for-release.outputs.dotnet-core-updated-sha }}
22
+ dotnet-release-notes : ${{ steps.check-for-release.outputs.dotnet-release-notes }}
22
23
dotnet-releases-updated : ${{ steps.check-for-release.outputs.dotnet-releases-updated }}
23
24
24
25
runs-on : [ ubuntu-latest ]
42
43
const currentSha = branch.data.commit.sha;
43
44
const previousSha = '${{ inputs.ref || vars.DOTNET_CORE_SHA }}';
44
45
45
- let releaseNotesUpdated = false ;
46
+ let releaseNotesFiles = [] ;
46
47
let updatedSha = '';
47
48
48
49
if (currentSha !== previousSha) {
@@ -52,12 +53,43 @@ jobs:
52
53
basehead: `${previousSha}...${currentSha}`,
53
54
});
54
55
updatedSha = currentSha;
55
- releaseNotesUpdated = diff.data.files
56
+ releaseNotesFiles = diff.data.files
56
57
.map(file => file.filename)
57
- .some(file => file.startsWith('release-notes/') && file.endsWith('/releases.json'));
58
+ .filter(file => file.startsWith('release-notes/') && file.endsWith('/releases.json'));
59
+ }
60
+
61
+ const releaseNotesUpdated = releaseNotesFiles.length > 0;
62
+ const releaseNotes = [];
63
+
64
+ if (releaseNotesUpdated) {
65
+ for (let path of releaseNotesFiles) {
66
+ const content = await github.rest.repos.getContent({
67
+ owner,
68
+ repo,
69
+ path,
70
+ ref: currentSha,
71
+ });
72
+ let release;
73
+ if (content.data.encoding === 'base64') {
74
+ release = Buffer.from(content.data.content, 'base64').toString();
75
+ } else if (content.data.encoding === 'none') {
76
+ const response = await fetch(content.data.download_url);
77
+ release = await response.text();
78
+ } else {
79
+ throw new Error(`Unexpected encoding for ${path}: ${content.data.encoding}`);
80
+ }
81
+
82
+ // Remove the releases array from the release notes
83
+ // otherwise the JSON is too large to use as an output.
84
+ const notes = JSON.parse(release);
85
+ delete notes.releases;
86
+
87
+ releaseNotes.push(notes);
88
+ }
58
89
}
59
90
60
91
core.setOutput('dotnet-core-updated-sha', updatedSha);
92
+ core.setOutput('dotnet-release-notes', JSON.stringify(releaseNotes));
61
93
core.setOutput('dotnet-releases-updated', releaseNotesUpdated);
62
94
63
95
update-sha :
@@ -104,9 +136,32 @@ jobs:
104
136
uses : actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
105
137
with :
106
138
script : |
107
- await github.rest.repos.createDispatchEvent({
108
- owner: context.repo.owner,
109
- repo: context.repo.repo,
110
- event_type: 'dotnet_release',
111
- client_payload: {}
112
- });
139
+ const releaseNotes = JSON.parse(`${{ needs.check-for-release.outputs.dotnet-release-notes }}`);
140
+ const isPreview = (release) => {
141
+ switch (release['support-phase']) {
142
+ case 'go-live':
143
+ case 'preview':
144
+ return true;
145
+ default:
146
+ return false;
147
+ }
148
+ };
149
+
150
+ const branchesToDispatch = [];
151
+ if (releaseNotes.some(release => isPreview(release))) {
152
+ branchesToDispatch.push('dotnet-vnext');
153
+ }
154
+ if (releaseNotes.some(release => !isPreview(release))) {
155
+ branchesToDispatch.push('main');
156
+ }
157
+
158
+ for (let branch of branchesToDispatch) {
159
+ await github.rest.repos.createDispatchEvent({
160
+ owner: context.repo.owner,
161
+ repo: context.repo.repo,
162
+ event_type: 'dotnet_release',
163
+ client_payload: {
164
+ branch
165
+ }
166
+ });
167
+ }
0 commit comments