forked from ava-labs/core-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.releaserc.js
141 lines (128 loc) · 3.64 KB
/
.releaserc.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
/*
This file contains the configuration for semantic release, the library we use to tag the correct
semantic version numbers onto releases. We have two release paths, one on main and one on release branch.
In the code below we check the env variable RELEASE_TYPE to decide what we should do. As of
the time of this file semantic release does not support specifying a config file from their CLI,
so this is the only we can have dynamic configs based on branch.
To test run this file, first get a github token at https://github.com/settings/tokens
and add it to the GITHUB_TOKEN env variable then specify what kind of release ou want to run (production or alpha) under RELEASE_TYPE
$ export GITHUB_TOKEN=<token>
$ export RELEASE_TYPE=<production or alpha>
$ run yarn run semantic-release -d
*/
const commitAnalyzerSetting = [
'@semantic-release/commit-analyzer',
{
preset: 'angular',
releaseRules: [
{
type: 'feat',
release: 'minor',
},
{
type: '*',
release: 'patch',
},
],
parserOpts: {
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
},
},
];
// used instead of `commitAnalyzerSetting` for prereleases
const execPatchAnyCommitSetting = [
'@semantic-release/exec',
{
analyzeCommitsCmd: 'echo patch',
},
];
const releaseReplaceSetting = [
'@google/semantic-release-replace-plugin',
{
replacements: [
{
files: ['dist/manifest.json'],
from: '"version": ".*"',
// Remove "-alpha" string from the version in the manifest.
// Chrome only supports numbers and dots in the version number.
to: `"version": "<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>"`,
results: [
{
file: 'dist/manifest.json',
hasChanged: true,
numMatches: 1,
numReplacements: 1,
},
],
countMatches: true,
},
{
files: ['dist/js/inpage.js'],
from: 'CORE_EXTENSION_VERSION',
// Replace CORE_EXTENSION_VERSION string to the next release number in the inpage.js file
to: `<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>`,
results: [
{
file: 'dist/js/inpage.js',
hasChanged: true,
numMatches: 1,
numReplacements: 1,
},
],
countMatches: true,
},
],
},
];
const githubSetting = [
'@semantic-release/github',
{
assets: [
{
path: 'builds/avalanche-wallet-extension.zip',
name: 'Avalanche-wallet-extension-${nextRelease.gitTag}.zip',
label: 'Wallet Extension (${nextRelease.gitTag})',
},
],
failTitle: false,
successComment: false,
failComment: false,
labels: false,
},
];
const execZipSetting = [
'@semantic-release/exec',
{
prepareCmd: 'yarn zip',
},
];
const execSentryReleaseSetting = [
'@semantic-release/exec',
{
prepareCmd: `yarn sentry core-extension@"<%= _.replace(nextRelease.version, /[^0-9.]/g, '') %>"`,
},
];
let plugins;
if (process.env && process.env.RELEASE_TYPE === 'production') {
plugins = [
commitAnalyzerSetting,
execSentryReleaseSetting,
releaseReplaceSetting,
execZipSetting,
githubSetting,
];
} else {
plugins = [
execPatchAnyCommitSetting,
execSentryReleaseSetting,
releaseReplaceSetting,
execZipSetting,
githubSetting,
];
}
module.exports = {
// define a main version release branch even though we are doing all releases from main
// this branch list gets overwritten in the production release Github Action
branches: ['release', { name: 'main', prerelease: 'alpha' }],
plugins,
};