@@ -5,7 +5,6 @@ import { getArrayInput, getStringInput } from '@elementor-editor-github-actions/
55import * as fs from 'fs' ;
66import { glob } from 'glob' ;
77
8- const packagesDir = 'packages' ;
98export async function run ( ) {
109 try {
1110 const inputs = parseInputs ( ) ;
@@ -15,14 +14,18 @@ export async function run() {
1514 message
1615 } = inputs ;
1716
18- await core . group ( 'Configuring git user' , async ( ) => {
17+ await core . group ( 'Validating git user configuration ' , async ( ) => {
1918 try {
20- await exec . exec ( 'git' , [ 'config' , 'user.name' , 'GitHub Actions '] ) ;
21- await exec . exec ( 'git' , [ 'config' , 'user.email' , 'github-actions@github.com '] ) ;
19+ const userName = await exec . getExecOutput ( 'git' , [ 'config' , 'user.name' ] ) ;
20+ const userEmail = await exec . getExecOutput ( 'git' , [ 'config' , 'user.email' ] ) ;
2221
23- core . info ( 'Git user configured' ) ;
22+ if ( ! userName . stdout . trim ( ) || ! userEmail . stdout . trim ( ) ) {
23+ throw new Error ( 'Git user is not configured properly' ) ;
24+ }
25+
26+ core . info ( 'Git user is properly configured' ) ;
2427 } catch ( error ) {
25- throw new Error ( `Failed to configure git user: ${ error } ` ) ;
28+ throw new Error ( `Failed to validate git user configuration : ${ error } ` ) ;
2629 }
2730 } ) ;
2831
@@ -33,9 +36,7 @@ export async function run() {
3336
3437 for ( const dir of targetDirectories ) {
3538 try {
36- const packageJsonFiles = await glob ( `${ packagesDir } /${ dir } /**/package.json` , {
37- ignore : [ '**/node_modules/**' ]
38- } ) ;
39+ const packageJsonFiles = await glob ( `${ dir } /*/package.json` ) ;
3940
4041 for ( const packageJsonPath of packageJsonFiles ) {
4142 const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf8' ) ) ;
@@ -50,7 +51,11 @@ export async function run() {
5051 if ( packageNames . length > 0 ) {
5152 core . info ( `Found ${ packageNames . length } packages to bump in target directories` ) ;
5253
53- const changesetId = Math . random ( ) . toString ( 36 ) . substring ( 2 , 12 ) ;
54+ await exec . exec ( 'npx' , [ 'changeset' , 'add' , '--empty' ] ) ;
55+
56+ const fileNames = await exec . getExecOutput ( 'ls' , [ '-t' , '.changeset' ] ) ;
57+
58+ const changesetId = fileNames . stdout . trim ( ) . split ( '\n' ) [ 0 ] ;
5459 const changesetDir = '.changeset' ;
5560
5661 if ( ! fs . existsSync ( changesetDir ) ) {
@@ -81,7 +86,7 @@ export async function run() {
8186
8287 await core . group ( 'Committing version changes' , async ( ) => {
8388 try {
84- await exec . exec ( 'git' , [ 'add' , '.' ] ) ;
89+ await exec . exec ( 'git' , [ 'add' , '.changeset ' ] ) ;
8590 await exec . exec ( 'git' , [ 'commit' , '-m' , message ] ) ;
8691
8792 await exec . exec ( 'git' , [ 'push' ] ) ;
0 commit comments