22 * Semantic Release Config
33 */
44
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';
712
813// Get env vars
914const ref = process . env . GITHUB_REF ;
@@ -24,7 +29,7 @@ const templates = {
2429async function config ( ) {
2530
2631 // Get branch
27- const branch = ref . split ( '/' ) . pop ( ) ;
32+ const branch = ref ? .split ( '/' ) ? .pop ( ) ?. split ( '-' ) [ 0 ] || '(current branch could not be determined)' ;
2833 console . log ( `Running on branch: ${ branch } ` ) ;
2934
3035 // Set changelog file
@@ -38,13 +43,10 @@ async function config() {
3843 branches : [
3944 'release' ,
4045 { name : 'alpha' , prerelease : true } ,
41- { name : 'beta' , prerelease : true } ,
46+ // { name: 'beta', prerelease: true },
4247 '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' ,
4850 ] ,
4951 dryRun : false ,
5052 debug : true ,
@@ -58,13 +60,13 @@ async function config() {
5860 { scope : 'no-release' , release : false } ,
5961 ] ,
6062 parserOpts : {
61- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ] ,
63+ noteKeywords : [ 'BREAKING CHANGE' ] ,
6264 } ,
6365 } ] ,
6466 [ '@semantic-release/release-notes-generator' , {
6567 preset : 'angular' ,
6668 parserOpts : {
67- noteKeywords : [ 'BREAKING CHANGE' , 'BREAKING CHANGES' , 'BREAKING' ]
69+ noteKeywords : [ 'BREAKING CHANGE' ]
6870 } ,
6971 writerOpts : {
7072 commitsSort : [ 'subject' , 'scope' ] ,
@@ -86,12 +88,13 @@ async function config() {
8688 [ '@semantic-release/github' , {
8789 successComment : getReleaseComment ( ) ,
8890 labels : [ 'type:ci' ] ,
89- releasedLabels : [ 'state:released<%= nextRelease.channel ? `-${nextRelease.channel}` : "" %>' ]
91+ releasedLabels : [ 'state:released<%= nextRelease.channel ? `-\ ${nextRelease.channel}` : "" %>' ]
9092 } ] ,
93+ // Back-merge module runs last because if it fails it should not impede the release process
9194 [
9295 '@saithodev/semantic-release-backmerge' ,
9396 {
94- 'branches ' : [
97+ 'backmergeBranches ' : [
9598 // { from: 'beta', to: 'alpha' },
9699 // { from: 'release', to: 'beta' },
97100 { from : 'release' , to : 'alpha' } ,
@@ -106,15 +109,17 @@ async function config() {
106109
107110async function loadTemplates ( ) {
108111 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' ) ;
110119 templates [ template ] . text = text ;
111120 }
112121}
113122
114- async function readFile ( filePath ) {
115- return await fs . readFile ( filePath , 'utf-8' ) ;
116- }
117-
118123function getReleaseComment ( ) {
119124 const url = repositoryUrl + '/releases/tag/${nextRelease.gitTag}' ;
120125 const comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')' ;
0 commit comments