@@ -6,11 +6,11 @@ const { join } = require("path");
66const { createHash } = require ( "crypto" ) ;
77
88/**
9- * Update Homebrew formula with new version and checksums
9+ * Generate Homebrew formula with new version and checksums
1010 * @param {string } version - Version string (e.g., "0.1.0")
1111 */
12- async function updateHomebrew ( version ) {
13- console . log ( `🍺 Updating Homebrew formula to v${ version } ...` ) ;
12+ async function generateHomebrew ( version ) {
13+ console . log ( `🍺 Generating Homebrew formula for v${ version } ...` ) ;
1414
1515 // Validate version format
1616 if ( ! / ^ \d + \. \d + \. \d + $ / . test ( version ) ) {
@@ -170,63 +170,20 @@ async function updateHomebrew(version) {
170170
171171 // Write updated formula
172172 writeFileSync ( formulaPath , updatedFormula ) ;
173- console . log ( "✅ Updated Formula/occtx.rb" ) ;
173+ console . log ( "✅ Generated Formula/occtx.rb" ) ;
174174
175175 // Show the updated content
176- console . log ( "\n📄 Updated formula content:" ) ;
176+ console . log ( "\n📄 Generated formula content:" ) ;
177177 console . log ( "=" . repeat ( 50 ) ) ;
178178 console . log ( updatedFormula ) ;
179179 console . log ( "=" . repeat ( 50 ) ) ;
180180
181- // Commit and push to homebrew-tap
182- console . log ( "\n🚀 Committing and pushing changes..." ) ;
183- try {
184- // Configure git if needed
185- try {
186- execSync ( 'git config user.name' , { cwd : homebrewPath , stdio : 'pipe' } ) ;
187- } catch {
188- execSync ( 'git config user.name "GitHub Actions"' , { cwd : homebrewPath } ) ;
189- execSync ( 'git config user.email "actions@github.com"' , { cwd : homebrewPath } ) ;
190- }
191-
192- // Add changes
193- execSync ( "git add ." , { cwd : homebrewPath } ) ;
194-
195- // Check if there are changes to commit
196- try {
197- execSync ( "git diff --cached --exit-code" , { cwd : homebrewPath , stdio : 'pipe' } ) ;
198- console . log ( "ℹ️ No changes to commit" ) ;
199- return ;
200- } catch {
201- // There are changes, continue with commit
202- }
203-
204- // Commit with detailed message
205- const commitMessage = `Update occtx to version ${ version }
206-
207- - Version: ${ version }
208- - macOS ARM64: ${ checksums [ 'macos-aarch64' ] }
209- - macOS x86_64: ${ checksums [ 'macos-x86_64' ] }
210- - Linux ARM64: ${ checksums [ 'linux-aarch64' ] }
211- - Linux x86_64: ${ checksums [ 'linux-x86_64' ] }
212- - Release: https://github.com/hungthai1401/occtx/releases/tag/v${ version }
213-
214- Auto-updated by GitHub Actions` ;
215-
216- execSync ( `git commit -m "${ commitMessage } "` , { cwd : homebrewPath } ) ;
217- // Push using the token if available (for GitHub Actions)
218- const token = process . env . GITHUB_TOKEN ;
219- if ( token ) {
220- execSync ( `git remote set-url origin https://${ token } @github.com/hungthai1401/homebrew-tap.git` , { cwd : homebrewPath } ) ;
221- }
222- execSync ( "git push origin main" , { cwd : homebrewPath } ) ;
223- console . log ( "✅ Pushed to homebrew-tap repository" ) ;
224- } catch ( error ) {
225- console . error ( "❌ Failed to update homebrew-tap:" , error . message ) ;
226- process . exit ( 1 ) ;
227- }
181+ // File generation completed - commit/push will be handled by GitHub Actions
182+ console . log ( "\n✅ Formula file generated successfully!" ) ;
183+ console . log ( "📝 Changes are ready for commit by GitHub Actions" ) ;
228184
229- console . log ( `\n🍺 Homebrew formula updated to v${ version } successfully! 🎉` ) ;
185+ console . log ( `\n🍺 Homebrew formula generated for v${ version } successfully! 🎉` ) ;
186+ console . log ( "📝 GitHub Actions will now commit and push the changes." ) ;
230187
231188 // Summary
232189 console . log ( "\n📊 Summary:" ) ;
@@ -238,7 +195,7 @@ Auto-updated by GitHub Actions`;
238195}
239196
240197// Export for use in other scripts
241- module . exports = { updateHomebrew } ;
198+ module . exports = { generateHomebrew } ;
242199
243200// Allow direct execution
244201if ( require . main === module ) {
@@ -247,16 +204,16 @@ if (require.main === module) {
247204 console . error ( "❌ Version is required!" ) ;
248205 console . error ( "" ) ;
249206 console . error ( "Usage:" ) ;
250- console . error ( " node .github/workflows/scripts/update -homebrew.js <version>" ) ;
251- console . error ( " OCCTX_VERSION=1.0.0 node .github/workflows/scripts/update -homebrew.js" ) ;
207+ console . error ( " node .github/workflows/scripts/generate -homebrew.js <version>" ) ;
208+ console . error ( " OCCTX_VERSION=1.0.0 node .github/workflows/scripts/generate -homebrew.js" ) ;
252209 console . error ( "" ) ;
253210 console . error ( "Examples:" ) ;
254- console . error ( " node .github/workflows/scripts/update -homebrew.js 1.0.0" ) ;
255- console . error ( " OCCTX_VERSION=1.0.0 node .github/workflows/scripts/update -homebrew.js" ) ;
211+ console . error ( " node .github/workflows/scripts/generate -homebrew.js 1.0.0" ) ;
212+ console . error ( " OCCTX_VERSION=1.0.0 node .github/workflows/scripts/generate -homebrew.js" ) ;
256213 process . exit ( 1 ) ;
257214 }
258215
259- updateHomebrew ( version ) . catch ( ( error ) => {
216+ generateHomebrew ( version ) . catch ( ( error ) => {
260217 console . error ( "❌ Script failed:" , error . message ) ;
261218 process . exit ( 1 ) ;
262219 } ) ;
0 commit comments