22 * Semantic Release Config
33 */
44
5- import fs from 'fs/promises' ;
6- import path from 'path' ;
5+ import { readFile } from 'fs/promises' ;
6+ import { resolve , dirname } from 'path' ;
7+ import { fileURLToPath } from 'url' ;
78
89// Get env vars
9- const ref = process . env . GITHUB_REF ;
10+ const ref = process . env . GITHUB_REF || '' ;
1011const serverUrl = process . env . GITHUB_SERVER_URL ;
1112const repository = process . env . GITHUB_REPOSITORY ;
1213const repositoryUrl = serverUrl + '/' + repository ;
@@ -38,6 +39,7 @@ async function config() {
3839 const config = {
3940 branches : [
4041 'master' ,
42+ 'ci/fix-auto-release' ,
4143 // { name: 'alpha', prerelease: true },
4244 // { name: 'beta', prerelease: true },
4345 // 'next-major',
@@ -49,7 +51,7 @@ async function config() {
4951 ] ,
5052 dryRun : true ,
5153 debug : true ,
52- ci : true ,
54+ ci : false ,
5355 tagFormat : '${version}' ,
5456 plugins : [
5557 [ '@semantic-release/commit-analyzer' , {
@@ -97,19 +99,17 @@ async function config() {
9799
98100async function loadTemplates ( ) {
99101 for ( const template of Object . keys ( templates ) ) {
100- const text = await readFile ( path . resolve ( __dirname , resourcePath , templates [ template ] . file ) ) ;
102+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
103+ const filePath = resolve ( __dirname , resourcePath , templates [ template ] . file ) ;
104+ const text = await readFile ( filePath , 'utf-8' ) ;
101105 templates [ template ] . text = text ;
102106 }
103107}
104108
105- async function readFile ( filePath ) {
106- return await fs . readFile ( filePath , 'utf-8' ) ;
107- }
108-
109109function getReleaseComment ( ) {
110110 const url = repositoryUrl + '/releases/tag/${nextRelease.gitTag}' ;
111111 let comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')' ;
112112 return comment ;
113113}
114114
115- module . exports = config ( ) ;
115+ export default config ( ) ;
0 commit comments