forked from algolia/shipjs
/
defaultConfig.js
168 lines (158 loc) · 5.28 KB
/
defaultConfig.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import shipJsVersion from '../../version';
export default {
remote: 'origin',
// monorepo: {
// mainVersionFile: 'package.json',
// packagesToBump: ['packages/*', 'examples/*'],
// packagesToPublish: ['packages/*'],
// },
shouldPrepare: undefined, // async ({ commits, nextVersion, releaseType, releaseTag, commitNumbersPerType }) => {},
updateChangelog: true,
conventionalChangelogArgs: '-p angular -i CHANGELOG.md -s',
installCommand: ({ isYarn }) =>
isYarn ? 'yarn install --silent' : 'npm install',
versionUpdated: undefined, // ({ version, releaseType, dir, exec }) => {},
getNextVersion: undefined, // ({ revisionRange, commitTitles, commitBodies, currentVersion, dir }) => {},
beforeCommitChanges: undefined, // ({ nextVersion, releaseType, exec, dir }) => {},
getStagingBranchName: ({ nextVersion, releaseType }) =>
`releases/v${nextVersion}`,
formatCommitMessage: ({ version, releaseType, baseBranch }) =>
`chore: release v${version}`,
formatPullRequestTitle: ({ version, releaseType }) =>
`chore: release v${version}`,
formatPullRequestMessage: ({
repo, // "instantsearch.js"
repoURL, // "https://github.com/algolia/instantsearch.js"
baseBranch, // "master"
stagingBranch, // "releases/v4.5.0"
destinationBranch, // "master"
releaseType, // "major" | "minor" | "patch" | "prerelease"
diffURL,
currentVersion,
nextVersion,
publishCommands, // either a string or an array (if monorepo)
title,
}) => {
const repoLink = `[${repo}](${repoURL})`;
const diffLink = `[\`${currentVersion}\` → \`${nextVersion}\`](${diffURL})`;
const publishCommandsTable =
typeof publishCommands === 'string'
? `\`\`\`${publishCommands}\`\`\``
: `
| Dir | Command |
|---|---|
${publishCommands
.map(({ dirName, command }) => `| ${dirName} | ${command} |`)
.join('\n')}
`.trim();
const mergeInstruction = `
When merging this pull request, you need to **Squash and merge** and make sure that the title starts with \`${title}\`.
<details>
<summary>See details</summary>
After that, a commit \`${title}\` will be added and you or your CI can run \`shipjs trigger\` to trigger the release based on the commit.
![Squash and merge](https://raw.githubusercontent.com/algolia/shipjs/v${shipJsVersion}/assets/squash-and-merge.png)
</details>
`.trim();
const message = `
This pull request prepares the following release:
| Repository | Branch | Update | Change |
|---|---|---|---|
| ${repoLink} | ${stagingBranch} | ${releaseType} | ${diffLink} |
### Release Summary
This is going to be published with the following command:
${publishCommandsTable}
### Merging Instructions
${mergeInstruction}
---
_This pull request is automatically generated by [Ship.js](https://github.com/algolia/shipjs)_.
`.trim();
return message;
},
draftPullRequest: false,
pullRequestReviewers: undefined,
pullRequestTeamReviewers: undefined,
shouldRelease: ({
commitMessage,
currentVersion,
currentBranch,
formatPullRequestTitle,
}) => {
if (currentBranch === `releases/v${currentVersion}`) {
return [
'It seems you ran `shipjs trigger` inside a release pull-request.',
'Merge this pull-request first, then run it again on your base branch.',
].join('\n');
}
const correctCommitMessage = formatPullRequestTitle({
version: currentVersion,
});
if (!commitMessage.trim().startsWith(correctCommitMessage)) {
return (
'The commit message should have started with the following:' +
'\n' +
`${correctCommitMessage}`
);
}
return true;
},
buildCommand: ({ isYarn }) => (isYarn ? 'yarn build' : 'npm run build'),
beforePublish: undefined, // ({ exec, dir }) => {}
publishCommand: ({ isYarn, tag, defaultCommand, dir }) => defaultCommand,
afterPublish: undefined, // ({ exec, dir, version, releaseTag }) => {}
getTagName: ({ version }) => `v${version}`,
testCommandBeforeRelease: undefined, // ({ isYarn }) => isYarn ? 'yarn test' : 'npm run test',
appName: undefined,
forcePushBranches: [],
slack: {
default: {
username: 'Ship.js',
// eslint-disable-next-line camelcase
icon_emoji: ':passenger_ship:',
},
prepared: ({ appName, version, pullRequestUrl }) => ({
pretext: `:writing_hand: The release for *${appName}@${version}* is prepared!`,
fields: [
{
title: 'Version',
value: version,
short: true,
},
{
title: 'Pull Request',
value: pullRequestUrl,
short: false,
},
],
}),
releaseSuccess: ({
appName,
version,
tagName,
latestCommitHash,
latestCommitUrl,
repoURL,
}) => ({
pretext: `:tada: Successfully released *${appName}@${version}*`,
fields: [
{
title: 'Commit',
value: `*<${latestCommitUrl}|${latestCommitHash}>*`,
short: true,
},
{
title: 'Version',
value: version,
short: true,
},
{
title: 'Release',
value: `${repoURL}/releases/tag/${tagName}`,
},
],
}),
},
releases: {
assetsToUpload: [],
extractChangelog: undefined, // ({ version, dir }) => `some specific changelog to that version`,
},
};