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,7 +29,7 @@ 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)' ;
28
33
console . log ( `Running on branch: ${ branch } ` ) ;
29
34
30
35
// Set changelog file
@@ -38,13 +43,10 @@ async function config() {
38
43
branches : [
39
44
'release' ,
40
45
{ name : 'alpha' , prerelease : true } ,
41
- { name : 'beta' , prerelease : true } ,
46
+ // { name: 'beta', prerelease: true },
42
47
'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' },
48
+ // Long-Term-Support branch
49
+ 'release-8.x.x' ,
48
50
] ,
49
51
dryRun : false ,
50
52
debug : true ,
@@ -58,13 +60,13 @@ async function config() {
58
60
{ scope : 'no-release' , release : false } ,
59
61
] ,
60
62
parserOpts : {
61
- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ] ,
63
+ noteKeywords : [ 'BREAKING CHANGE' ] ,
62
64
} ,
63
65
} ] ,
64
66
[ '@semantic-release/release-notes-generator' , {
65
67
preset : 'angular' ,
66
68
parserOpts : {
67
- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ]
69
+ noteKeywords : [ 'BREAKING CHANGE' ]
68
70
} ,
69
71
writerOpts : {
70
72
commitsSort : [ 'subject' , 'scope' ] ,
@@ -86,12 +88,13 @@ async function config() {
86
88
[ '@semantic-release/github' , {
87
89
successComment : getReleaseComment ( ) ,
88
90
labels : [ 'type:ci' ] ,
89
- releasedLabels : [ 'state:released<%= nextRelease.channel ? `-${nextRelease.channel}` : "" %>' ]
91
+ releasedLabels : [ 'state:released<%= nextRelease.channel ? `-\ ${nextRelease.channel}` : "" %>' ]
90
92
} ] ,
93
+ // Back-merge module runs last because if it fails it should not impede the release process
91
94
[
92
95
'@saithodev/semantic-release-backmerge' ,
93
96
{
94
- 'branches ' : [
97
+ 'backmergeBranches ' : [
95
98
// { from: 'beta', to: 'alpha' },
96
99
// { from: 'release', to: 'beta' },
97
100
{ from : 'release' , to : 'alpha' } ,
@@ -106,15 +109,17 @@ async function config() {
106
109
107
110
async function loadTemplates ( ) {
108
111
for ( const template of Object . keys ( templates ) ) {
109
- const text = await readFile ( path . resolve ( __dirname , resourcePath , templates [ template ] . file ) ) ;
112
+
113
+ // For ES6 modules use:
114
+ // const fileUrl = import.meta.url;
115
+ // const __dirname = dirname(fileURLToPath(fileUrl));
116
+
117
+ const filePath = resolve ( __dirname , resourcePath , templates [ template ] . file ) ;
118
+ const text = await readFile ( filePath , 'utf-8' ) ;
110
119
templates [ template ] . text = text ;
111
120
}
112
121
}
113
122
114
- async function readFile ( filePath ) {
115
- return await fs . readFile ( filePath , 'utf-8' ) ;
116
- }
117
-
118
123
function getReleaseComment ( ) {
119
124
const url = repositoryUrl + '/releases/tag/${nextRelease.gitTag}' ;
120
125
const comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')' ;
0 commit comments