28
28
PR_TEMPLATE=$( cat .github/check-new-release/templates/pr.md)
29
29
PR_BODY=" "
30
30
31
+ # Initialize workflow update status flag
32
+ WORKFLOW_UPDATED=" false"
33
+
31
34
# Version update function
32
35
update_version () {
33
36
local type=$1
@@ -113,48 +116,54 @@ update_version() {
113
116
fi
114
117
fi
115
118
116
- # Automatically update workflow files
119
+ # Check workflow files for potential updates (but don't modify)
117
120
local workflow_files=$( find .github/workflows -name " docker-*.yml" 2> /dev/null || echo " " )
118
121
if [[ -n " $workflow_files " ]]; then
119
- echo " Automatically updating workflow files..."
122
+ echo " Checking workflow files for necessary updates (will not modify them) ..."
120
123
121
124
local version_pattern=" version: ${major_version} \\ .x"
122
125
local version_replace=" version: ${short_version} "
123
126
124
- if [[ " $DRY_RUN " != " true" ]]; then
125
- # Execute for each file
126
- for workflow_file in $workflow_files ; do
127
- if grep -q " $version_pattern " " $workflow_file " ; then
128
- echo " Updating: $workflow_file "
129
- sed -i " s/$version_pattern /$version_replace /g" " $workflow_file "
130
- if [ $? -ne 0 ]; then
131
- echo " ::warning::Failed to update version in $workflow_file "
132
- echo " Failed to update workflow file $workflow_file but will continue with the process."
133
- fi
134
- else
135
- echo " ::info::No matching pattern found, no update needed: $workflow_file "
136
- fi
137
- done
138
- else
139
- echo " dry run: Files to be updated:"
140
- for workflow_file in $workflow_files ; do
141
- if grep -q " $version_pattern " " $workflow_file " ; then
142
- echo " dry run: Update '$version_pattern ' to '$version_replace ' in $workflow_file "
143
- echo " dry run: Command to execute: sed -i \" s/$version_pattern /$version_replace /g\" \" $workflow_file \" "
144
- fi
145
- done
146
- fi
127
+ # Create a section in PR body for workflow file updates
128
+ WORKFLOW_INSTRUCTIONS=" "
129
+ local any_needs_update=false
147
130
148
- # Add workflow file update note to PR description
149
- PR_BODY=" ${PR_BODY} (Workflow files were automatically updated)"
131
+ # Check each workflow file
132
+ for workflow_file in $workflow_files ; do
133
+ if grep -q " $version_pattern " " $workflow_file " ; then
134
+ any_needs_update=true
135
+ echo " Found workflow file needing update: $workflow_file "
136
+
137
+ # Get the line number and context for the PR description
138
+ local line_info=$( grep -n " $version_pattern " " $workflow_file " )
139
+ local line_num=$( echo " $line_info " | cut -d' :' -f1)
140
+ local line_content=$( echo " $line_info " | cut -d' :' -f2-)
141
+
142
+ # Add to workflow update instructions
143
+ WORKFLOW_INSTRUCTIONS=" ${WORKFLOW_INSTRUCTIONS}
144
+ - **$workflow_file ** (line $line_num ):
145
+ - From: \` $line_content \`
146
+ - To: \` $( echo " $line_content " | sed " s/$version_pattern /$version_replace /" ) \` "
147
+ else
148
+ echo " ::info::No matching pattern found, no update needed: $workflow_file "
149
+ fi
150
+ done
151
+
152
+ # Set flag if any workflows need updates
153
+ if [[ " $any_needs_update " == " true" ]]; then
154
+ WORKFLOW_UPDATED=" true"
155
+ echo " ⚠️ Found workflow files that need manual updates (details will be in PR description)"
156
+ fi
150
157
else
151
158
echo " ::warning::No workflow files found."
159
+ # No files found
160
+ echo " ⚠️ No workflow files found for checking"
152
161
fi
153
162
154
163
# Add version update details to PR body (formatted)
155
164
PR_BODY=" ${PR_BODY}
156
165
157
- ### ${type^} Version Update
166
+ ### $( if [[ " $type " == " lts " ]] ; then echo " LTS " ; else echo " $ {type^}" ; fi ) Version Update
158
167
* **${current_version} ** → **${new_version} **"
159
168
160
169
# Success log
@@ -176,12 +185,31 @@ PR_BODY="${PR_BODY}
176
185
177
186
## Update Content
178
187
- Updated version numbers in Dockerfiles
179
- - Updated version references in README.md
180
- - Automatically updated workflow files
188
+ - Updated version references in README.md"
189
+
190
+ # Add workflow update instructions if needed
191
+ if [[ " ${WORKFLOW_UPDATED:- } " == " true" && -n " ${WORKFLOW_INSTRUCTIONS:- } " ]]; then
192
+ PR_BODY=" ${PR_BODY}
193
+
194
+ ## ⚠️ Required Manual Updates for Workflow Files
195
+ For security reasons, workflow files cannot be automatically updated by GitHub Actions.
196
+ Please manually update the following files:
197
+ ${WORKFLOW_INSTRUCTIONS}
198
+
199
+ You can apply these changes by:
200
+ 1. Checking out the branch: \` git checkout ${BRANCH_NAME} \`
201
+ 2. Making the changes shown above
202
+ 3. Committing and pushing: \` git commit -am 'Update workflow versions' && git push\` "
203
+ else
204
+ PR_BODY=" ${PR_BODY}
205
+ - ✓ No workflow file updates needed"
206
+ fi
207
+
208
+ PR_BODY=" ${PR_BODY}
181
209
182
210
## ⚠️ Notes
183
- 1. If workflow files were not automatically updated, please update them manually
184
- 2. Please verify all file changes before merging "
211
+ 1. Please verify all file changes before merging
212
+ 2. Workflow files require manual updates (if any are listed above) "
185
213
186
214
# Commit and push changes
187
215
changed_files=$( git status --porcelain | awk ' {print $2}' )
0 commit comments