@@ -11,7 +11,6 @@ import (
1111 "github.com/githubnext/gh-aw/pkg/console"
1212 "github.com/githubnext/gh-aw/pkg/constants"
1313 "github.com/githubnext/gh-aw/pkg/parser"
14- "github.com/githubnext/gh-aw/pkg/workflow"
1514 "github.com/spf13/cobra"
1615)
1716
@@ -25,7 +24,7 @@ func NewUpdateCommand(validateEngine func(string) error) *cobra.Command {
2524The command:
26251. Checks if a newer version of gh-aw is available
27262. Updates workflows using the 'source' field in the workflow frontmatter
28- 3. Recompiles all workflows
27+ 3. Compiles each workflow immediately after update
2928
3029For workflow updates, it fetches the latest version based on the current ref:
3130- If the ref is a tag, it updates to the latest release (use --major for major version updates)
@@ -109,54 +108,23 @@ func checkExtensionUpdate(verbose bool) error {
109108 return nil
110109}
111110
112- // runCompileWorkflows runs the compile command to recompile all workflows
113- func runCompileWorkflows (verbose bool , engineOverride string , workflowsDir string ) error {
114- if verbose {
115- fmt .Fprintln (os .Stderr , console .FormatVerboseMessage ("Compiling workflows..." ))
116- }
117-
118- // Create a compiler instance similar to how compile command does it
119- compiler := workflow .NewCompiler (verbose , engineOverride , GetVersion ())
120-
121- // Use provided workflows directory or default
122- if workflowsDir == "" {
123- workflowsDir = getWorkflowsDir ()
124- }
125-
126- // Compile all workflows in the workflows directory
127- _ , err := compileAllWorkflowFiles (compiler , workflowsDir , verbose )
128- if err != nil {
129- return fmt .Errorf ("failed to compile workflows: %w" , err )
130- }
131-
132- if verbose {
133- fmt .Fprintln (os .Stderr , console .FormatSuccessMessage ("Successfully compiled all workflows" ))
134- }
135- return nil
136- }
137-
138111// UpdateWorkflowsWithExtensionCheck performs the complete update process:
139112// 1. Check for gh-aw extension updates
140- // 2. Update workflows from source repositories
141- // 3. Compile all workflows
142- // 4. Optionally create a PR
113+ // 2. Update workflows from source repositories (compiles each workflow after update)
114+ // 3. Optionally create a PR
143115func UpdateWorkflowsWithExtensionCheck (workflowNames []string , allowMajor , force , verbose bool , engineOverride string , createPR bool , workflowsDir string ) error {
144116 // Step 1: Check for gh-aw extension updates
145117 if err := checkExtensionUpdate (verbose ); err != nil {
146118 return fmt .Errorf ("extension update check failed: %w" , err )
147119 }
148120
149121 // Step 2: Update workflows from source repositories
122+ // Note: Each workflow is compiled immediately after update
150123 if err := UpdateWorkflows (workflowNames , allowMajor , force , verbose , engineOverride , workflowsDir ); err != nil {
151124 return fmt .Errorf ("workflow update failed: %w" , err )
152125 }
153126
154- // Step 3: Compile all workflows
155- if err := runCompileWorkflows (verbose , engineOverride , workflowsDir ); err != nil {
156- return fmt .Errorf ("compile failed: %w" , err )
157- }
158-
159- // Step 4: Optionally create PR if flag is set
127+ // Step 3: Optionally create PR if flag is set
160128 if createPR {
161129 if err := createUpdatePR (verbose ); err != nil {
162130 return fmt .Errorf ("failed to create PR: %w" , err )
@@ -271,21 +239,29 @@ func UpdateWorkflows(workflowNames []string, allowMajor, force, verbose bool, en
271239
272240 fmt .Fprintln (os .Stderr , console .FormatInfoMessage (fmt .Sprintf ("Found %d workflow(s) to update" , len (workflows ))))
273241
242+ // Track update results
243+ var successfulUpdates []string
244+ var failedUpdates []updateFailure
245+
274246 // Update each workflow
275- updatedCount := 0
276247 for _ , wf := range workflows {
277248 if err := updateWorkflow (wf , allowMajor , force , verbose , engineOverride ); err != nil {
278- fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to update %s: %v" , wf .Name , err )))
249+ failedUpdates = append (failedUpdates , updateFailure {
250+ Name : wf .Name ,
251+ Error : err .Error (),
252+ })
279253 continue
280254 }
281- updatedCount ++
255+ successfulUpdates = append ( successfulUpdates , wf . Name )
282256 }
283257
284- if updatedCount == 0 {
258+ // Show summary
259+ showUpdateSummary (successfulUpdates , failedUpdates )
260+
261+ if len (successfulUpdates ) == 0 {
285262 return fmt .Errorf ("no workflows were successfully updated" )
286263 }
287264
288- fmt .Fprintln (os .Stderr , console .FormatSuccessMessage (fmt .Sprintf ("Successfully updated %d workflow(s)" , updatedCount )))
289265 return nil
290266}
291267
@@ -296,6 +272,37 @@ type workflowWithSource struct {
296272 SourceSpec string // e.g., "owner/repo/path@ref"
297273}
298274
275+ // updateFailure represents a failed workflow update
276+ type updateFailure struct {
277+ Name string
278+ Error string
279+ }
280+
281+ // showUpdateSummary displays a summary of workflow updates using console helpers
282+ func showUpdateSummary (successfulUpdates []string , failedUpdates []updateFailure ) {
283+ fmt .Fprintln (os .Stderr , "" )
284+ fmt .Fprintln (os .Stderr , console .FormatInfoMessage ("=== Update Summary ===" ))
285+ fmt .Fprintln (os .Stderr , "" )
286+
287+ // Show successful updates
288+ if len (successfulUpdates ) > 0 {
289+ fmt .Fprintln (os .Stderr , console .FormatSuccessMessage (fmt .Sprintf ("Successfully updated and compiled %d workflow(s):" , len (successfulUpdates ))))
290+ for _ , name := range successfulUpdates {
291+ fmt .Fprintf (os .Stderr , " ✓ %s\n " , name )
292+ }
293+ fmt .Fprintln (os .Stderr , "" )
294+ }
295+
296+ // Show failed updates
297+ if len (failedUpdates ) > 0 {
298+ fmt .Fprintln (os .Stderr , console .FormatErrorMessage (fmt .Sprintf ("Failed to update %d workflow(s):" , len (failedUpdates ))))
299+ for _ , failure := range failedUpdates {
300+ fmt .Fprintf (os .Stderr , " ✗ %s: %s\n " , failure .Name , failure .Error )
301+ }
302+ fmt .Fprintln (os .Stderr , "" )
303+ }
304+ }
305+
299306// findWorkflowsWithSource finds all workflows that have a source field
300307func findWorkflowsWithSource (workflowsDir string , filterNames []string , verbose bool ) ([]* workflowWithSource , error ) {
301308 var workflows []* workflowWithSource
0 commit comments