Skip to content

Commit 2abfaa7

Browse files
committed
ci: bump node talisman version as patch for new tw talisman version
1 parent 6f82ba9 commit 2abfaa7

3 files changed

Lines changed: 118 additions & 19 deletions

File tree

package-lock.json

Lines changed: 94 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"lint-staged": "^10.4.0",
8484
"prettier": "^2.1.2",
8585
"replace-in-file": "^6.1.0",
86+
"semver": "^7.3.8",
8687
"ts-jest": "^26.4.0",
8788
"ts-node": "^9.0.0",
8889
"typescript": "^4.0.3"

scripts/release/index.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,30 @@ const fs = require('fs');
77
const request = require('request');
88
const execShPromise = require('exec-sh').promise;
99
const replace = require('replace-in-file');
10+
const semver = require('semver');
1011

12+
const packageJson = require('../../package.json');
1113
const { CHECKSUMS, META_INFO } = require('../../src/constants');
1214

13-
const oldVersion = META_INFO.version.replace('v', '');
15+
const oldTWTalismanVersion = META_INFO.version.replace('v', '');
16+
const { version: oldNodeTalismanVersion } = packageJson;
1417

15-
const publishNewTag = async ({ newVersion }) => {
16-
await execShPromise(`npm run publish -- ${newVersion} --no-release-draft`, {
17-
cwd: process.cwd(),
18-
});
18+
const publishNewTag = async () => {
19+
const newNodeTalismanVersion = semver.inc(oldNodeTalismanVersion, 'patch');
20+
21+
await execShPromise(
22+
`npm run publish -- ${newNodeTalismanVersion} --no-release-draft`,
23+
{
24+
cwd: process.cwd(),
25+
},
26+
);
1927
};
2028

21-
const commitChanges = async ({ newVersion }) => {
29+
const commitChanges = async ({ newTWTalismanVersion }) => {
2230
await execShPromise(
2331
[
2432
'git add --all',
25-
`git commit -m "build(tw-talisman): upgrade from ${oldVersion} to ${newVersion}" -n`,
33+
`git commit -m "build(tw-talisman): upgrade from ${oldTWTalismanVersion} to ${newTWTalismanVersion}" -n`,
2634
],
2735
{ cwd: process.cwd() },
2836
);
@@ -47,14 +55,14 @@ const replaceChecksumsInFiles = async ({ checksums }) => {
4755
}
4856
};
4957

50-
const replaceVersionsInFiles = ({ tagName }) => {
58+
const replaceVersionsInFiles = ({ newTWTalismanVersion }) => {
5159
const cwd = process.cwd();
5260

5361
try {
5462
const changedFiles = replace.sync({
5563
files: [`${cwd}/README.md`, `${cwd}/src/constants.ts`],
56-
from: new RegExp(`v${oldVersion}`, 'g'),
57-
to: tagName,
64+
from: new RegExp(`v${oldTWTalismanVersion}`, 'g'),
65+
to: `v${newTWTalismanVersion}`,
5866
});
5967

6068
console.log('Modified files after replacing versions:', changedFiles);
@@ -100,7 +108,7 @@ const getChecksumFileContent = ({ tagName }) => {
100108

101109
const getNextValidTagName = (body) => {
102110
const index = body.findIndex(({ tag_name: tagName }) =>
103-
tagName.includes(oldVersion),
111+
tagName.includes(oldTWTalismanVersion),
104112
);
105113

106114
let nextValidTag = null;
@@ -153,7 +161,7 @@ const getNextTagName = () => {
153161
const tagName = await getNextTagName();
154162

155163
if (tagName) {
156-
const newVersion = tagName.replace('v', '');
164+
const newTWTalismanVersion = tagName.replace('v', '');
157165

158166
const checksumFileContent = await getChecksumFileContent({ tagName });
159167
const checksums = extractChecksumsFromContent({
@@ -163,11 +171,11 @@ const getNextTagName = () => {
163171

164172
await replaceChecksumsInFiles({ checksums });
165173

166-
replaceVersionsInFiles({ tagName });
174+
replaceVersionsInFiles({ newTWTalismanVersion });
167175

168-
await commitChanges({ newVersion });
176+
await commitChanges({ newTWTalismanVersion });
169177

170-
await publishNewTag({ newVersion });
178+
await publishNewTag();
171179
}
172180
} catch (error) {
173181
setImmediate(() => {

0 commit comments

Comments
 (0)