1- # !/bin/bash (実行権限を付与せずbashコマンドで実行されるため実際には使用されない )
2- # 厳格モードを設定
1+ # !/bin/bash (This is not used as the script is executed with bash command without execution permission )
2+ # Set strict mode
33set -eu
44
5- # dry runモードを確認
5+ # Check if in dry run mode
66if [[ " $DRY_RUN " == " true" ]]; then
7- echo " ::notice::dry runモードで実行しています。実際の変更は行いません。 "
7+ echo " ::notice::Running in dry run mode. No actual changes will be made. "
88fi
99
10- # ブランチ作成
11- BRANCH_NAME=" bot/update-mysql-shell-$( date +%Y%m%d%H%M%S) "
10+ # Use the BRANCH_NAME environment variable passed from the workflow
11+ # Verify that BRANCH_NAME is set
12+ if [[ -z " ${BRANCH_NAME:- } " ]]; then
13+ echo " ::error::BRANCH_NAME environment variable is not set. This should be set by the workflow."
14+ exit 1
15+ fi
16+
17+ echo " Using branch name: $BRANCH_NAME "
18+
1219if [[ " $DRY_RUN " != " true" ]]; then
1320 git config --global user.name ' github-actions[bot]'
1421 git config --global user.email ' github-actions[bot]@users.noreply.github.com'
1724 echo " dry run: git checkout -b $BRANCH_NAME "
1825fi
1926
20- # PR本文の初期化
27+ # Initialize PR body
2128PR_TEMPLATE=$( cat .github/check-new-release/templates/pr.md)
2229PR_BODY=" "
2330
24- # バージョン更新関数
31+ # Version update function
2532update_version () {
2633 local type=$1
2734 local current_version=$2
@@ -32,52 +39,52 @@ update_version() {
3239
3340 echo " Updating $type to $new_version (major.minor: $short_version )..."
3441
35- # Dockerfile の更新
42+ # Update Dockerfile
3643 if [[ " $DRY_RUN " != " true" ]]; then
3744 if ! sed -i " s/^ARG MYSQL_SHELL_VERSION=.*/ARG MYSQL_SHELL_VERSION=$new_version /" docker/$type /Dockerfile; then
3845 echo " ::error::Failed to update version in docker/$type /Dockerfile"
39- echo " このエラーは重要なファイル更新に失敗したため、処理を中断します。 "
46+ echo " This is a critical error while updating an important file. Aborting. "
4047 exit 1
4148 fi
4249
43- # 更新が成功したか検証
50+ # Verify the update was successful
4451 if ! grep -q " ARG MYSQL_SHELL_VERSION=$new_version " docker/$type /Dockerfile; then
4552 echo " ::error::Version update in docker/$type /Dockerfile could not be verified"
46- echo " Dockerfileの更新内容を確認できないため処理を中断します。 "
53+ echo " Cannot verify Dockerfile update. Aborting. "
4754 exit 1
4855 fi
4956 else
50- # dry runモードではより詳細な情報を表示
51- echo " dry run: 実行予定のコマンド : sed -i \" s/^ARG MYSQL_SHELL_VERSION=.*/ARG MYSQL_SHELL_VERSION=$new_version /\" docker/$type /Dockerfile"
52- echo " dry run: docker/ $type /Dockerfile 内の ARG MYSQL_SHELL_VERSION=$current_version を $new_version に更新 "
57+ # Show more detailed information in dry run mode
58+ echo " dry run: Command to execute : sed -i \" s/^ARG MYSQL_SHELL_VERSION=.*/ARG MYSQL_SHELL_VERSION=$new_version /\" docker/$type /Dockerfile"
59+ echo " dry run: Update ARG MYSQL_SHELL_VERSION=$current_version to $new_version in docker/ $type /Dockerfile "
5360 fi
5461
55- # README.md の更新
62+ # Update README.md
5663 if [[ " $type " == " innovation" ]]; then
5764 local match_pattern=" Innovation Series ([0-9]\\ .[0-9]\\ .[x0-9])"
5865 local replace_value=" Innovation Series (${major_version} .${minor_version} .x)"
5966 local tag_pattern=" snickerjp\/docker-mysql-shell:${major_version} \\ .[0-9]"
6067 local tag_replace=" snickerjp\/docker-mysql-shell:${short_version} "
6168
6269 if [[ " $DRY_RUN " != " true" ]]; then
63- # READMEの更新は重要だが失敗しても処理は継続する
70+ # README updates are important but we continue even if they fail
6471 sed -i " s/$match_pattern /$replace_value /g" README.md
6572 if [ $? -ne 0 ]; then
6673 echo " ::warning::Failed to update Innovation Series version in README.md"
67- echo " README.mdの更新に失敗しましたが、処理は継続します。 "
74+ echo " Failed to update README.md but will continue with the process. "
6875 fi
6976
7077 sed -i " s/$tag_pattern /$tag_replace /g" README.md
7178 if [ $? -ne 0 ]; then
7279 echo " ::warning::Failed to update Innovation image tag in README.md"
73- echo " README.mdのタグ更新に失敗しましたが、処理は継続します。 "
80+ echo " Failed to update tag in README.md but will continue with the process. "
7481 fi
7582 else
76- # dry runモードではより詳細な情報を表示
77- echo " dry run: 実行予定のコマンド : sed -i \" s/$match_pattern /$replace_value /g\" README.md"
78- echo " dry run: 実行予定のコマンド : sed -i \" s/$tag_pattern /$tag_replace /g\" README.md"
79- echo " dry run: README.md 内の '$match_pattern ' を '$replace_value ' に更新 "
80- echo " dry run: README.md 内の '$tag_pattern ' を '$tag_replace ' に更新 "
83+ # Show more detailed information in dry run mode
84+ echo " dry run: Command to execute : sed -i \" s/$match_pattern /$replace_value /g\" README.md"
85+ echo " dry run: Command to execute : sed -i \" s/$tag_pattern /$tag_replace /g\" README.md"
86+ echo " dry run: Update '$match_pattern ' to '$replace_value ' in README.md "
87+ echo " dry run: Update '$tag_pattern ' to '$tag_replace ' in README.md "
8188 fi
8289 else
8390 local match_pattern=" LTS Series ([0-9]\\ .[0-9]\\ .[x0-9])"
@@ -89,118 +96,118 @@ update_version() {
8996 sed -i " s/$match_pattern /$replace_value /g" README.md
9097 if [ $? -ne 0 ]; then
9198 echo " ::warning::Failed to update LTS Series version in README.md"
92- echo " README.mdの更新に失敗しましたが、処理は継続します。 "
99+ echo " Failed to update README.md but will continue with the process. "
93100 fi
94101
95102 sed -i " s/$tag_pattern /$tag_replace /g" README.md
96103 if [ $? -ne 0 ]; then
97104 echo " ::warning::Failed to update LTS image tag in README.md"
98- echo " README.mdのタグ更新に失敗しましたが、処理は継続します。 "
105+ echo " Failed to update tag in README.md but will continue with the process. "
99106 fi
100107 else
101- # dry runモードではより詳細な情報を表示
102- echo " dry run: 実行予定のコマンド : sed -i \" s/$match_pattern /$replace_value /g\" README.md"
103- echo " dry run: 実行予定のコマンド : sed -i \" s/$tag_pattern /$tag_replace /g\" README.md"
104- echo " dry run: README.md 内の '$match_pattern ' を '$replace_value ' に更新 "
105- echo " dry run: README.md 内の '$tag_pattern ' を '$tag_replace ' に更新 "
108+ # Show more detailed information in dry run mode
109+ echo " dry run: Command to execute : sed -i \" s/$match_pattern /$replace_value /g\" README.md"
110+ echo " dry run: Command to execute : sed -i \" s/$tag_pattern /$tag_replace /g\" README.md"
111+ echo " dry run: Update '$match_pattern ' to '$replace_value ' in README.md "
112+ echo " dry run: Update '$tag_pattern ' to '$tag_replace ' in README.md "
106113 fi
107114 fi
108115
109- # ワークフローファイルの自動更新
116+ # Automatically update workflow files
110117 local workflow_files=$( find .github/workflows -name " docker-*.yml" 2> /dev/null || echo " " )
111118 if [[ -n " $workflow_files " ]]; then
112- echo " ワークフローファイルを自動的に更新します ..."
119+ echo " Automatically updating workflow files ..."
113120
114121 local version_pattern=" version: ${major_version} \\ .x"
115122 local version_replace=" version: ${short_version} "
116123
117124 if [[ " $DRY_RUN " != " true" ]]; then
118- # 各ファイルに対して実行
125+ # Execute for each file
119126 for workflow_file in $workflow_files ; do
120127 if grep -q " $version_pattern " " $workflow_file " ; then
121- echo " 更新 : $workflow_file "
128+ echo " Updating : $workflow_file "
122129 sed -i " s/$version_pattern /$version_replace /g" " $workflow_file "
123130 if [ $? -ne 0 ]; then
124131 echo " ::warning::Failed to update version in $workflow_file "
125- echo " ワークフローファイル $workflow_file の更新に失敗しましたが、処理は継続します。 "
132+ echo " Failed to update workflow file $workflow_file but will continue with the process. "
126133 fi
127134 else
128- echo " ::info::該当するパターンがないため更新不要 : $workflow_file "
135+ echo " ::info::No matching pattern found, no update needed : $workflow_file "
129136 fi
130137 done
131138 else
132- echo " dry run: 以下のファイルを更新予定 :"
139+ echo " dry run: Files to be updated :"
133140 for workflow_file in $workflow_files ; do
134141 if grep -q " $version_pattern " " $workflow_file " ; then
135- echo " dry run: $workflow_file 内の '$version_pattern ' を '$version_replace ' に更新 "
136- echo " dry run: 実行予定のコマンド : sed -i \" s/$version_pattern /$version_replace /g\" \" $workflow_file \" "
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 \" "
137144 fi
138145 done
139146 fi
140147
141- # PR説明文にワークフローファイル更新の旨を追加
142- PR_BODY=" ${PR_BODY} (ワークフローファイルも自動的に更新されました )"
148+ # Add workflow file update note to PR description
149+ PR_BODY=" ${PR_BODY} (Workflow files were automatically updated )"
143150 else
144- echo " ::warning::ワークフローファイルが見つかりませんでした。 "
151+ echo " ::warning::No workflow files found. "
145152 fi
146153
147- # PR本文に変更内容を追加(整形された形式で)
154+ # Add version update details to PR body (formatted)
148155 PR_BODY=" ${PR_BODY}
149156
150- ### ${type^} バージョン更新
157+ ### ${type^} Version Update
151158* **${current_version} ** → **${new_version} **"
152159
153- # 成功ログ
154- echo " ✅ $type のバージョン更新が完了しました "
160+ # Success log
161+ echo " ✅ $type version update completed "
155162}
156163
157- # Innovation の更新
164+ # Update Innovation
158165if [[ " $INNOVATION_UPDATE_NEEDED " == " true" ]]; then
159166 update_version " innovation" " $CURRENT_INNOVATION " " $LATEST_INNOVATION "
160167fi
161168
162- # LTS の更新
169+ # Update LTS
163170if [[ " $LTS_UPDATE_NEEDED " == " true" ]]; then
164171 update_version " lts" " $CURRENT_LTS " " $LATEST_LTS "
165172fi
166173
167- # PR本文に必要な手順を追加
174+ # Add necessary steps to PR body
168175PR_BODY=" ${PR_BODY}
169176
170- ## 更新内容
171- - Dockerfileのバージョン番号更新
172- - README.mdのバージョン表記を更新
173- - ワークフローファイルを自動的に更新
177+ ## Update Content
178+ - Updated version numbers in Dockerfiles
179+ - Updated version references in README.md
180+ - Automatically updated workflow files
174181
175- ## ⚠️ 注意事項
176- 1. ワークフローファイルの自動更新が行われていない場合は手動で更新してください
177- 2. マージ前に各ファイルの更新内容を確認してください "
182+ ## ⚠️ Notes
183+ 1. If workflow files were not automatically updated, please update them manually
184+ 2. Please verify all file changes before merging "
178185
179- # 変更をコミットしてプッシュ
186+ # Commit and push changes
180187changed_files=$( git status --porcelain | awk ' {print $2}' )
181188if [[ -z " $changed_files " ]]; then
182189 echo " No changes to commit."
183190 exit 0
184191fi
185192
186- # ファイルの変更をチェック
193+ # Check changed files
187194echo " Changed files:"
188195for file in $changed_files ; do
189196 echo " - $file "
190197done
191198
192- # すべての変更をステージング
199+ # Stage all changes
193200if [[ " $DRY_RUN " != " true" ]]; then
194201 git add $changed_files
195202 git commit -m " Update MySQL Shell versions (Innovation: $LATEST_INNOVATION , LTS: $LATEST_LTS )"
196203
197- # エラーハンドリング付きでプッシュ
204+ # Push with error handling
198205 if ! git push origin $BRANCH_NAME ; then
199206 echo " ::error::Failed to push changes to GitHub"
200207 exit 1
201208 fi
202209
203- # プルリクエストを作成
210+ # Create pull request
204211 if ! gh pr create \
205212 --base develop \
206213 --head $BRANCH_NAME \
@@ -212,13 +219,13 @@ if [[ "$DRY_RUN" != "true" ]]; then
212219
213220 echo " Pull request created successfully!"
214221else
215- echo " dry run: 以下のファイルが変更されます :"
222+ echo " dry run: The following files would be changed :"
216223 for file in $changed_files ; do
217224 echo " - $file "
218225 done
219- echo " dry run: コミットメッセージ : Update MySQL Shell versions (Innovation: $LATEST_INNOVATION , LTS: $LATEST_LTS )"
220- echo " dry run: PR作成: タイトル : Update MySQL Shell versions (Innovation: $LATEST_INNOVATION , LTS: $LATEST_LTS )"
221- echo " dry run: PR本文 :"
226+ echo " dry run: Commit message : Update MySQL Shell versions (Innovation: $LATEST_INNOVATION , LTS: $LATEST_LTS )"
227+ echo " dry run: PR creation: Title : Update MySQL Shell versions (Innovation: $LATEST_INNOVATION , LTS: $LATEST_LTS )"
228+ echo " dry run: PR body :"
222229 echo -e " $PR_BODY "
223- echo " dry run終了: 実際の変更は行われていません。 "
230+ echo " dry run completed: No actual changes were made. "
224231fi
0 commit comments