Skip to content

Commit 5cb88f4

Browse files
Run SDK update for previews (#33)
See which .NET release channels were updated and then dispatch one or more `dotnet_release` events based on whether the releases were stable or not.
1 parent 4c69f3b commit 5cb88f4

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed

.github/workflows/dotnet-release.yml

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919

2020
outputs:
2121
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 }}
2223
dotnet-releases-updated: ${{ steps.check-for-release.outputs.dotnet-releases-updated }}
2324

2425
runs-on: [ ubuntu-latest ]
@@ -42,7 +43,7 @@ jobs:
4243
const currentSha = branch.data.commit.sha;
4344
const previousSha = '${{ inputs.ref || vars.DOTNET_CORE_SHA }}';
4445
45-
let releaseNotesUpdated = false;
46+
let releaseNotesFiles = [];
4647
let updatedSha = '';
4748
4849
if (currentSha !== previousSha) {
@@ -52,12 +53,43 @@ jobs:
5253
basehead: `${previousSha}...${currentSha}`,
5354
});
5455
updatedSha = currentSha;
55-
releaseNotesUpdated = diff.data.files
56+
releaseNotesFiles = diff.data.files
5657
.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+
}
5889
}
5990
6091
core.setOutput('dotnet-core-updated-sha', updatedSha);
92+
core.setOutput('dotnet-release-notes', JSON.stringify(releaseNotes));
6193
core.setOutput('dotnet-releases-updated', releaseNotesUpdated);
6294
6395
update-sha:
@@ -104,9 +136,32 @@ jobs:
104136
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
105137
with:
106138
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+
}

.github/workflows/update-dotnet-sdks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
env:
2929
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
3030
run: |
31-
$branch = "${{ inputs.branch || 'main' }}"
31+
$branch = "${{ (github.event.client_payload && github.event.client_payload.branch) || inputs.branch || 'main' }}"
3232
$repos = @(
3333
"justeattakeaway/ApplePayJSSample",
3434
"justeattakeaway/httpclient-interception",

0 commit comments

Comments
 (0)