Skip to content

Commit b6574fd

Browse files
committed
fix(all): release independently each language
1 parent 12f9c4c commit b6574fd

File tree

4 files changed

+57
-69
lines changed

4 files changed

+57
-69
lines changed

clients/algoliasearch-client-java-2/.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-java@v3
2424
with:
2525
distribution: zulu
26-
java-version-file: config/.java-version
26+
java-version-file: .java-version
2727
cache: gradle
2828

2929
- name: Validate gradle wrapper
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.0.18

clients/algoliasearch-client-javascript/.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
**dist
2-
**.openapi-generator
2+
**.openapi-generator*
3+
4+
.DS_Store
5+
.env
36

47
yarn-error.log
58

@@ -8,5 +11,3 @@ yarn-error.log
811
!.yarn/plugins
912

1013
node_modules
11-
12-
node_

scripts/ci/codegen/spreadGeneration.ts

Lines changed: 51 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,10 @@ import {
1313
} from '../../common';
1414
import { getLanguageFolder, getPackageVersionDefault } from '../../config';
1515
import { RELEASED_TAG } from '../../release/common';
16-
import type { Language } from '../../types';
1716
import { cloneRepository, getNbGitDiff } from '../utils';
1817

1918
import text, { commitStartRelease } from './text';
2019

21-
export function decideWhereToSpread(commitMessage: string): Language[] {
22-
if (commitMessage.startsWith(commitStartRelease)) {
23-
return LANGUAGES;
24-
}
25-
26-
const result = commitMessage.match(/(.+)\((.+)\):/);
27-
if (!result) {
28-
// no scope
29-
return LANGUAGES;
30-
}
31-
32-
const scope = result[2] as Language;
33-
return LANGUAGES.includes(scope) ? [scope] : LANGUAGES;
34-
}
35-
3620
export function cleanUpCommitMessage(
3721
commitMessage: string,
3822
version: string
@@ -84,10 +68,9 @@ async function spreadGeneration(): Promise<void> {
8468
.filter(Boolean);
8569

8670
const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(commitStartRelease);
87-
const langs = decideWhereToSpread(lastCommitMessage);
8871
console.log(
8972
'Spreading code to the following repositories:',
90-
langs.join(' | ')
73+
LANGUAGES.join(' | ')
9174
);
9275

9376
// At this point, we know the release will happen on at least one client
@@ -99,67 +82,70 @@ async function spreadGeneration(): Promise<void> {
9982
await run(
10083
`git fetch origin refs/tags/${RELEASED_TAG}:refs/tags/${RELEASED_TAG}`
10184
);
102-
await run(`git tag -d ${RELEASED_TAG}`);
10385
await run(`git push --delete origin ${RELEASED_TAG}`);
10486

10587
console.log('Creating new `released` tag for latest commit');
10688
await run(`git tag ${RELEASED_TAG}`);
10789
await run('git push --tags');
10890
}
10991

110-
for (const lang of langs) {
111-
const { tempGitDir } = await cloneRepository({
112-
lang,
113-
githubToken,
114-
tempDir: process.env.RUNNER_TEMP!,
115-
});
116-
117-
const clientPath = toAbsolutePath(getLanguageFolder(lang));
118-
await emptyDirExceptForDotGit(tempGitDir);
119-
await copy(clientPath, tempGitDir, { preserveTimestamps: true });
120-
121-
if (
122-
(await getNbGitDiff({
123-
head: null,
92+
for (const lang of LANGUAGES) {
93+
try {
94+
const { tempGitDir } = await cloneRepository({
95+
lang,
96+
githubToken,
97+
tempDir: process.env.RUNNER_TEMP!,
98+
});
99+
100+
const clientPath = toAbsolutePath(getLanguageFolder(lang));
101+
await emptyDirExceptForDotGit(tempGitDir);
102+
await copy(clientPath, tempGitDir, { preserveTimestamps: true });
103+
104+
if (
105+
(await getNbGitDiff({
106+
head: null,
107+
cwd: tempGitDir,
108+
})) === 0
109+
) {
110+
console.log(
111+
`❎ Skipping ${lang} repository, because there is no change.`
112+
);
113+
continue;
114+
} else {
115+
console.log(`✅ Spreading code to the ${lang} repository.`);
116+
}
117+
118+
const version = getPackageVersionDefault(lang);
119+
const commitMessage = cleanUpCommitMessage(lastCommitMessage, version);
120+
121+
await configureGitHubAuthor(tempGitDir);
122+
123+
await run('git add .', { cwd: tempGitDir });
124+
await gitCommit({
125+
message: commitMessage,
126+
coAuthors: [author, ...coAuthors],
124127
cwd: tempGitDir,
125-
})) === 0
126-
) {
127-
console.log(
128-
`❎ Skipping ${lang} repository, because there is no change.`
129-
);
130-
continue;
131-
} else {
132-
console.log(`✅ Spreading code to the ${lang} repository.`);
133-
}
134-
135-
const version = getPackageVersionDefault(lang);
136-
const commitMessage = cleanUpCommitMessage(lastCommitMessage, version);
128+
});
129+
await run('git push', { cwd: tempGitDir });
137130

138-
await configureGitHubAuthor(tempGitDir);
131+
// In case of a release commit, we also want to update tags on the clients repositories
132+
if (IS_RELEASE_COMMIT) {
133+
console.log(
134+
`Processing release commit, creating new release tag ('${version}') for '${lang}' repository.`
135+
);
139136

140-
await run('git add .', { cwd: tempGitDir });
141-
await gitCommit({
142-
message: commitMessage,
143-
coAuthors: [author, ...coAuthors],
144-
cwd: tempGitDir,
145-
});
146-
await run('git push', { cwd: tempGitDir });
137+
// we always want to delete the tag in case it exists
138+
await run(`git tag -d ${version} || true`, { cwd: tempGitDir });
139+
await run(`git tag ${version} HEAD`, { cwd: tempGitDir });
140+
await run('git push --tags', { cwd: tempGitDir });
141+
}
147142

148-
// In case of a release commit, we also want to update tags on the clients repositories
149-
if (IS_RELEASE_COMMIT) {
150143
console.log(
151-
`Processing release commit, creating new release tag ('${version}') for '${lang}' repository.`
144+
`✅ Code generation successfully pushed to ${lang} repository.`
152145
);
153-
154-
// we always want to delete the tag in case it exists
155-
await run(`git tag -d ${version} || true`, { cwd: tempGitDir });
156-
await run(`git tag ${version} HEAD`, { cwd: tempGitDir });
157-
await run('git push --tags', { cwd: tempGitDir });
146+
} catch (e) {
147+
console.error(`Release failed for language ${lang}: ${e}`);
158148
}
159-
160-
console.log(
161-
`✅ Code generation successfully pushed to ${lang} repository.`
162-
);
163149
}
164150
}
165151

0 commit comments

Comments
 (0)