@@ -82,6 +82,34 @@ function classifyCommit(message) {
8282 return null ;
8383}
8484
85+ function getGitHubReleaseTitle ( tag , callback ) {
86+ const options = {
87+ hostname : "api.github.com" ,
88+ path : `/repos/DroidWorksStudio/mLauncher/releases/tags/${ tag } ` ,
89+ method : "GET" ,
90+ headers : {
91+ "User-Agent" : "Node.js" ,
92+ "Accept" : "application/vnd.github.v3+json"
93+ } ,
94+ } ;
95+
96+ const req = https . request ( options , ( res ) => {
97+ let data = "" ;
98+ res . on ( "data" , ( chunk ) => data += chunk ) ;
99+ res . on ( "end" , ( ) => {
100+ if ( res . statusCode >= 200 && res . statusCode < 300 ) {
101+ const json = JSON . parse ( data ) ;
102+ callback ( null , json . name || tag ) ; // release title
103+ } else {
104+ callback ( new Error ( `GitHub API returned ${ res . statusCode } : ${ data } ` ) ) ;
105+ }
106+ } ) ;
107+ } ) ;
108+
109+ req . on ( "error" , ( e ) => callback ( e ) ) ;
110+ req . end ( ) ;
111+ }
112+
85113// Get latest tag
86114const allTags = run ( "git tag --sort=-creatordate" ) . split ( "\n" ) ;
87115const latestTag = allTags [ 0 ] ;
@@ -108,52 +136,53 @@ for (const c of commits) {
108136}
109137
110138// Build plain message
111- let discordMessage = `## Multi Launcher ${ latestTag } \n\n` ;
112-
113- for ( const group of GROUP_ORDER ) {
114- if ( ! groups [ group ] || groups [ group ] . length === 0 ) continue ;
115- discordMessage += `${ group } \n${ groups [ group ] . join ( "\n" ) } \n\n` ;
116- }
117-
118- // Fallback
119- if ( ! commits . length ) discordMessage += "No commits found." ;
120-
121- // Append Discord Role mention
122- discordMessage += `<@&${ process . env . DISCORD_ROLEID } >\n\n` ;
123-
124- // Append download link
125- discordMessage += `:arrow_down: [Direct APK Download](<${ REPO_URL } /releases/download/${ latestTag } /MultiLauncher-${ latestTag } -Signed.apk>) :arrow_down:\n\n` ;
126-
127- // Send to Discord
128- const payload = JSON . stringify ( {
129- content : discordMessage ,
130- username : "Multi Launcher Updates" ,
131- avatar_url : "https://github.com/DroidWorksStudio/mLauncher/blob/main/fastlane/metadata/android/en-US/images/icon.png?raw=true" ,
132- } ) ;
133-
134- const url = new URL ( WEBHOOK_URL ) ;
135- const options = {
136- hostname : url . hostname ,
137- path : url . pathname + url . search ,
138- method : "POST" ,
139- headers : {
140- "Content-Type" : "application/json" ,
141- "Content-Length" : payload . length ,
142- } ,
143- } ;
144-
145- const req = https . request ( options , ( res ) => {
146- let data = "" ;
147- res . on ( "data" , ( chunk ) => ( data += chunk ) ) ;
148- res . on ( "end" , ( ) => {
149- if ( res . statusCode >= 200 && res . statusCode < 300 ) {
150- console . log ( "✅ Release posted to Discord!" ) ;
151- } else {
152- console . error ( "Failed to post:" , res . statusCode , data ) ;
153- }
154- } ) ;
139+ // Fetch release title and then build/send Discord message
140+ getGitHubReleaseTitle ( latestTag , ( err , releaseTitle ) => {
141+ if ( err ) return console . error ( "Error fetching release:" , err ) ;
142+
143+ // Build Discord message AFTER fetching release title
144+ let discordMessage = `## ${ releaseTitle } \n\n` ;
145+
146+ for ( const group of GROUP_ORDER ) {
147+ if ( ! groups [ group ] || groups [ group ] . length === 0 ) continue ;
148+ discordMessage += `${ group } \n${ groups [ group ] . join ( "\n" ) } \n\n` ;
149+ }
150+
151+ if ( ! commits . length ) discordMessage += "No commits found." ;
152+
153+ discordMessage += `<@&${ process . env . DISCORD_ROLEID } >\n\n` ;
154+ discordMessage += `:arrow_down: [Direct APK Download](${ REPO_URL } /releases/download/${ latestTag } /MultiLauncher-${ latestTag } -Signed.apk) :arrow_down:\n\n` ;
155+
156+ const payload = JSON . stringify ( {
157+ content : discordMessage ,
158+ username : "Multi Launcher Updates" ,
159+ avatar_url : "https://github.com/DroidWorksStudio/mLauncher/blob/main/fastlane/metadata/android/en-US/images/icon.png?raw=true" ,
160+ } ) ;
161+
162+ const url = new URL ( WEBHOOK_URL ) ;
163+ const options = {
164+ hostname : url . hostname ,
165+ path : url . pathname + url . search ,
166+ method : "POST" ,
167+ headers : {
168+ "Content-Type" : "application/json" ,
169+ "Content-Length" : payload . length ,
170+ } ,
171+ } ;
172+
173+ const req = https . request ( options , ( res ) => {
174+ let data = "" ;
175+ res . on ( "data" , ( chunk ) => ( data += chunk ) ) ;
176+ res . on ( "end" , ( ) => {
177+ if ( res . statusCode >= 200 && res . statusCode < 300 ) {
178+ console . log ( "✅ Release posted to Discord!" ) ;
179+ } else {
180+ console . error ( "Failed to post:" , res . statusCode , data ) ;
181+ }
182+ } ) ;
183+ } ) ;
184+
185+ req . on ( "error" , ( e ) => console . error ( "Error:" , e ) ) ;
186+ req . write ( payload ) ;
187+ req . end ( ) ;
155188} ) ;
156-
157- req . on ( "error" , ( e ) => console . error ( "Error:" , e ) ) ;
158- req . write ( payload ) ;
159- req . end ( ) ;
0 commit comments