Skip to content

Commit 28e3987

Browse files
committed
chore: nextgen release configs
1 parent c05d28d commit 28e3987

File tree

1 file changed

+84
-45
lines changed

1 file changed

+84
-45
lines changed

.releaserc.js

Lines changed: 84 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,63 +48,102 @@ const hasNextGenBuild =
4848
process.env.NEXT_GEN_BUILD_STATUS === 'success' &&
4949
fs.existsSync('dist-next/manifest.json');
5050

51-
const manifestReplacePaths = ['dist/manifest.json'];
52-
const inpageReplacePaths = ['dist/inpage/js/inpage.js'];
51+
const replacementConfig = [
52+
{
53+
files: 'dist/manifest.json',
54+
from: '"version": ".*"',
55+
// Remove "-alpha" string from the version in the manifest.
56+
// Chrome only supports numbers and dots in the version number.
57+
to: `"version": "<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>"`,
58+
results: [
59+
{
60+
file: 'dist/manifest.json',
61+
hasChanged: true,
62+
numMatches: 1,
63+
numReplacements: 1,
64+
},
65+
],
66+
countMatches: true,
67+
},
68+
{
69+
files: 'dist/inpage/js/inpage.js',
70+
from: 'CORE_EXTENSION_VERSION',
71+
// Replace CORE_EXTENSION_VERSION string to the next release number in the inpage.js file
72+
to: `<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>`,
73+
results: [
74+
{
75+
file: 'dist/inpage/js/inpage.js',
76+
hasChanged: true,
77+
numMatches: 2,
78+
numReplacements: 2,
79+
},
80+
],
81+
countMatches: true,
82+
},
83+
];
5384

5485
if (hasNextGenBuild) {
55-
manifestReplacePaths.push('dist-next/manifest.json');
56-
inpageReplacePaths.push('dist-next/inpage/js/inpage.js');
86+
replacementConfig.push(
87+
{
88+
files: 'dist-next/manifest.json',
89+
from: '"version": ".*"',
90+
// Remove "-alpha" string from the version in the manifest.
91+
// Chrome only supports numbers and dots in the version number.
92+
to: `"version": "<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>"`,
93+
results: [
94+
{
95+
file: 'dist-next/manifest.json',
96+
hasChanged: true,
97+
numMatches: 1,
98+
numReplacements: 1,
99+
},
100+
],
101+
countMatches: true,
102+
},
103+
{
104+
files: 'dist-next/inpage/js/inpage.js',
105+
from: 'CORE_EXTENSION_VERSION',
106+
// Replace CORE_EXTENSION_VERSION string to the next release number in the inpage.js file
107+
to: `<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>`,
108+
results: [
109+
{
110+
file: 'dist-next/inpage/js/inpage.js',
111+
hasChanged: true,
112+
numMatches: 2,
113+
numReplacements: 2,
114+
},
115+
],
116+
countMatches: true,
117+
},
118+
);
57119
}
58120

59121
const releaseReplaceSetting = [
60122
'@google/semantic-release-replace-plugin',
61123
{
62-
replacements: [
63-
{
64-
files: manifestReplacePaths,
65-
from: '"version": ".*"',
66-
// Remove "-alpha" string from the version in the manifest.
67-
// Chrome only supports numbers and dots in the version number.
68-
to: `"version": "<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>"`,
69-
results: [
70-
{
71-
file: 'dist/manifest.json',
72-
hasChanged: true,
73-
numMatches: 1,
74-
numReplacements: 1,
75-
},
76-
],
77-
countMatches: true,
78-
},
79-
{
80-
files: inpageReplacePaths,
81-
from: 'CORE_EXTENSION_VERSION',
82-
// Replace CORE_EXTENSION_VERSION string to the next release number in the inpage.js file
83-
to: `<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>`,
84-
results: [
85-
{
86-
file: 'dist/inpage/js/inpage.js',
87-
hasChanged: true,
88-
numMatches: 2,
89-
numReplacements: 2,
90-
},
91-
],
92-
countMatches: true,
93-
},
94-
],
124+
replacements: replacementConfig,
95125
},
96126
];
97127

128+
const assets = [
129+
{
130+
path: 'builds/avalanche-wallet-extension.zip',
131+
name: 'Avalanche-wallet-extension-${nextRelease.gitTag}.zip',
132+
label: 'Wallet Extension (${nextRelease.gitTag})',
133+
},
134+
];
135+
136+
if (hasNextGenBuild) {
137+
assets.push({
138+
path: 'builds/avalanche-wallet-extension-next.zip',
139+
name: 'NextGen-Core-Extension-${nextRelease.gitTag}.zip',
140+
label: '[NextGen] Core Extension (${nextRelease.gitTag})',
141+
});
142+
}
98143
const githubSetting = [
99144
'@semantic-release/github',
100145
{
101-
assets: [
102-
{
103-
path: 'builds/avalanche-wallet-extension.zip',
104-
name: 'Avalanche-wallet-extension-${nextRelease.gitTag}.zip',
105-
label: 'Wallet Extension (${nextRelease.gitTag})',
106-
},
107-
],
146+
assets,
108147
failTitle: false,
109148
successComment: false,
110149
failComment: false,
@@ -115,7 +154,7 @@ const githubSetting = [
115154
const execZipSetting = [
116155
'@semantic-release/exec',
117156
{
118-
prepareCmd: 'yarn zip',
157+
prepareCmd: hasNextGenBuild ? 'yarn zip && yarn zip:next' : 'yarn zip',
119158
},
120159
];
121160

0 commit comments

Comments
 (0)