forked from algolia/react-instantsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ship.config.js
129 lines (123 loc) · 3.49 KB
/
ship.config.js
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
const fs = require('fs');
const path = require('path');
const getLatestVersion = require('latest-version');
const packages = [
'packages/react-instantsearch-core',
'packages/react-instantsearch-dom-maps',
'packages/react-instantsearch-dom',
'packages/react-instantsearch-hooks',
'packages/react-instantsearch-native',
'packages/react-instantsearch',
];
module.exports = {
monorepo: {
mainVersionFile: 'lerna.json',
packagesToBump: packages,
packagesToPublish: packages,
},
versionUpdated: ({ version, exec, dir }) => {
// Update version in `react-instantsearch-core`
fs.writeFileSync(
path.resolve(
dir,
'packages',
'react-instantsearch-core',
'src',
'core',
'version.js'
),
`export default '${version}';\n`
);
// Update version in `react-instantsearch-hooks`
fs.writeFileSync(
path.resolve(
dir,
'packages',
'react-instantsearch-hooks',
'src',
'version.ts'
),
`export default '${version}';\n`
);
// update version in top level package
exec(`mversion ${version}`);
// update version in packages & dependencies
exec(`lerna version ${version} --no-git-tag-version --no-push --yes`);
// @TODO: We can remove after initial npm release of `react-instantsearch-hooks`
// We update the Hooks package dependency in the example because Lerna doesn't
// and releasing fails because the Hooks package has not yet been released on npm.
exec(
`yarn workspace hooks-example upgrade react-instantsearch-hooks@${version}`
);
},
shouldPrepare: ({ releaseType, commitNumbersPerType }) => {
const { fix = 0 } = commitNumbersPerType;
if (releaseType === 'patch' && fix === 0) {
return false;
}
return true;
},
pullRequestTeamReviewers: ['instantsearch-for-websites'],
buildCommand: ({ version }) =>
`NODE_ENV=production VERSION=${version} yarn build`,
afterPublish: async ({ exec, version }) => {
await waitUntil(async () => {
const latestVersion = await getLatestVersion('react-instantsearch', {
version: 'latest',
});
return latestVersion === version;
});
exec(`git config --global user.email "[email protected]"`);
exec(`git config --global user.name "InstantSearch"`);
exec(`node scripts/update-examples.js ${version}`);
exec(`git push origin master`);
},
slack: {
// disable slack notification for `prepared` lifecycle.
// Ship.js will send slack message only for `releaseSuccess`.
prepared: null,
releaseSuccess: ({
appName,
version,
tagName,
latestCommitHash,
latestCommitUrl,
repoURL,
}) => ({
pretext: [`:tada: Successfully released *${appName}@${version}*`].join(
'\n'
),
fields: [
{
title: 'Branch',
value: 'master',
short: true,
},
{
title: 'Commit',
value: `*<${latestCommitUrl}|${latestCommitHash}>*`,
short: true,
},
{
title: 'Version',
value: version,
short: true,
},
{
title: 'Release',
value: `${repoURL}/releases/tag/${tagName}`,
},
],
}),
},
};
function waitUntil(checkFn) {
return new Promise((resolve) => {
const intervalId = setInterval(async () => {
if (await checkFn()) {
clearInterval(intervalId);
resolve();
}
}, 3000);
});
}