Skip to content

Commit 4d2a348

Browse files
authored
chore(scripts): allow retry of the release (#5223)
1 parent c831d95 commit 4d2a348

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

.github/workflows/check.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,17 +693,29 @@ jobs:
693693
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
694694

695695
- name: Wait for all release CI
696+
id: waitForAllReleases
696697
run: yarn workspace scripts waitForAllReleases ${{ steps.spreadGeneration.outputs.PUSHED_LANGUAGES }}
697698
env:
698699
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
699700

700701
- name: Create GitHub release
701-
run: yarn workspace scripts createGitHubReleases ${{ steps.spreadGeneration.outputs.PUSHED_LANGUAGES }}
702+
run: yarn workspace scripts createGitHubReleases ${{ steps.waitForAllReleases.outputs.RELEASED_LANGUAGES }}
702703
env:
703704
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
704705

705-
- name: Push generated files to repositories
706+
- name: Push generated files to doc/dashboard repositories
706707
run: yarn workspace scripts pushToRepository
708+
if: ${{ steps.waitForAllReleases.outputs.CAN_PUSH_TO_REPO == 'true' }}
707709
env:
708710
GH_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
709711
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
712+
713+
- name: notify failures
714+
uses: slackapi/[email protected]
715+
if: ${{ steps.waitForAllReleases.outputs.FAILED_RELEASES != '' }}
716+
with:
717+
method: chat.postMessage
718+
token: ${{ secrets.SLACK_BOT_TOKEN }}
719+
payload: |
720+
channel: ${{ secrets.SLACK_CHANNEL_ID }}
721+
text: ":alert: Some clients failed to release :alert: \n${{ steps.waitForAllReleases.outputs.FAILED_RELEASES }}\nYou can retry the CI jobs to release them again, it will not affect already released clients."

scripts/ci/codegen/spreadGeneration.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ async function spreadGeneration(): Promise<void> {
5252
if (IS_RELEASE_COMMIT) {
5353
console.log('Creating new `released` tag for latest commit');
5454
await run(`git tag ${await getNewReleasedTag()}`);
55-
await run('git push --tags');
55+
try {
56+
await run('git push --tags');
57+
} catch (e) {
58+
console.error('Failed to push tags, it might already exist, ignoring error.', e);
59+
}
5660
}
5761

5862
const pushed: Language[] = [];
@@ -62,7 +66,7 @@ async function spreadGeneration(): Promise<void> {
6266
const { tempGitDir } = await cloneRepository({
6367
lang,
6468
githubToken,
65-
tempDir: process.env.RUNNER_TEMP!,
69+
tempDir: process.env.RUNNER_TEMP || '/tmp',
6670
});
6771

6872
const clientPath = toAbsolutePath(getLanguageFolder(lang));

scripts/ci/codegen/waitForAllReleases.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as core from '@actions/core';
12
import type { components } from '@octokit/openapi-types';
23

34
import { exists, getOctokit, run, setVerbose, toAbsolutePath } from '../../common.ts';
@@ -125,8 +126,12 @@ async function waitForAllReleases(languagesReleased: Language[]): Promise<void>
125126
}
126127

127128
if (failures.length > 0) {
128-
throw new Error(`${failures.join(', ')} failed to release`);
129+
console.error(`${failures.join(', ')} releases failed, please check the CI logs.`);
130+
core.setOutput('FAILED_RELEASES', failures.join(' '));
129131
}
132+
133+
core.setOutput('CAN_PUSH_TO_REPO', true);
134+
core.setOutput('RELEASED_LANGUAGES', languagesReleased.filter((lang) => !failures.includes(lang)).join(' '));
130135
}
131136

132137
if (import.meta.url.endsWith(process.argv[1])) {

0 commit comments

Comments
 (0)