2
2
* Semantic Release Config
3
3
*/
4
4
5
- const fs = require ( 'fs' ) . promises ;
6
- const path = require ( 'path' ) ;
5
+ const { readFile } = require ( 'fs' ) . promises ;
6
+ const { resolve } = require ( 'path' ) ;
7
+
8
+ // For ES6 modules use:
9
+ // import { readFile } from 'fs/promises';
10
+ // import { resolve, dirname } from 'path';
11
+ // import { fileURLToPath } from 'url';
7
12
8
13
// Get env vars
9
14
const ref = process . env . GITHUB_REF ;
@@ -24,11 +29,13 @@ const templates = {
24
29
async function config ( ) {
25
30
26
31
// Get branch
27
- const branch = ref . split ( '/' ) . pop ( ) ;
32
+ const branch = ref ?. split ( '/' ) ?. pop ( ) ?. split ( '-' ) [ 0 ] || '(current branch could not be determined)' ;
33
+ // eslint-disable-next-line no-console
28
34
console . log ( `Running on branch: ${ branch } ` ) ;
29
35
30
36
// Set changelog file
31
37
const changelogFile = `./changelogs/CHANGELOG_${ branch } .md` ;
38
+ // eslint-disable-next-line no-console
32
39
console . log ( `Changelog file output to: ${ changelogFile } ` ) ;
33
40
34
41
// Load template file contents
@@ -38,13 +45,10 @@ async function config() {
38
45
branches : [
39
46
'release' ,
40
47
{ name : 'alpha' , prerelease : true } ,
41
- { name : 'beta' , prerelease : true } ,
48
+ // { name: 'beta', prerelease: true },
42
49
'next-major' ,
43
- // Long-Term-Support branches
44
- // { name: 'release-1', range: '1.x.x', channel: '1.x' },
45
- // { name: 'release-2', range: '2.x.x', channel: '2.x' },
46
- // { name: 'release-3', range: '3.x.x', channel: '3.x' },
47
- // { name: 'release-4', range: '4.x.x', channel: '4.x' },
50
+ // Long-Term-Support branch
51
+ 'release-8.x.x' ,
48
52
] ,
49
53
dryRun : false ,
50
54
debug : true ,
@@ -58,13 +62,13 @@ async function config() {
58
62
{ scope : 'no-release' , release : false } ,
59
63
] ,
60
64
parserOpts : {
61
- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ] ,
65
+ noteKeywords : [ 'BREAKING CHANGE' ] ,
62
66
} ,
63
67
} ] ,
64
68
[ '@semantic-release/release-notes-generator' , {
65
69
preset : 'angular' ,
66
70
parserOpts : {
67
- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ]
71
+ noteKeywords : [ 'BREAKING CHANGE' ]
68
72
} ,
69
73
writerOpts : {
70
74
commitsSort : [ 'subject' , 'scope' ] ,
@@ -86,12 +90,13 @@ async function config() {
86
90
[ '@semantic-release/github' , {
87
91
successComment : getReleaseComment ( ) ,
88
92
labels : [ 'type:ci' ] ,
89
- releasedLabels : [ 'state:released<%= nextRelease.channel ? `-${nextRelease.channel}` : "" %>' ]
93
+ releasedLabels : [ 'state:released<%= nextRelease.channel ? `-\ ${nextRelease.channel}` : "" %>' ]
90
94
} ] ,
95
+ // Back-merge module runs last because if it fails it should not impede the release process
91
96
[
92
- ' @saithodev/semantic-release-backmerge' ,
97
+ " @saithodev/semantic-release-backmerge" ,
93
98
{
94
- 'branches' : [
99
+ "backmergeBranches" : [
95
100
// { from: 'beta', to: 'alpha' },
96
101
// { from: 'release', to: 'beta' },
97
102
{ from : 'release' , to : 'alpha' } ,
@@ -106,15 +111,17 @@ async function config() {
106
111
107
112
async function loadTemplates ( ) {
108
113
for ( const template of Object . keys ( templates ) ) {
109
- const text = await readFile ( path . resolve ( __dirname , resourcePath , templates [ template ] . file ) ) ;
114
+
115
+ // For ES6 modules use:
116
+ // const fileUrl = import.meta.url;
117
+ // const __dirname = dirname(fileURLToPath(fileUrl));
118
+
119
+ const filePath = resolve ( __dirname , resourcePath , templates [ template ] . file ) ;
120
+ const text = await readFile ( filePath , 'utf-8' ) ;
110
121
templates [ template ] . text = text ;
111
122
}
112
123
}
113
124
114
- async function readFile ( filePath ) {
115
- return await fs . readFile ( filePath , 'utf-8' ) ;
116
- }
117
-
118
125
function getReleaseComment ( ) {
119
126
const url = repositoryUrl + '/releases/tag/${nextRelease.gitTag}' ;
120
127
const comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')' ;
0 commit comments