Skip to content

Commit daa678d

Browse files
authored
Merge pull request #65 from snickerjp/develop
# Release 2025-04-26 10:31:12
2 parents 5eea729 + bee0665 commit daa678d

File tree

6 files changed

+62
-38
lines changed

6 files changed

+62
-38
lines changed

.github/check-new-release/scripts/update.sh

+31-6
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,54 @@ update_version() {
121121
if [[ -n "$workflow_files" ]]; then
122122
echo "Checking workflow files for necessary updates (will not modify them)..."
123123

124-
local version_pattern="version: ${major_version}\\.x"
125-
local version_replace="version: ${short_version}"
124+
# Create patterns to match both formats: version: X.Y and version: X.x
125+
local version_pattern1="version: ${major_version}\\.x"
126+
local version_replace1="version: ${short_version}"
127+
local version_pattern2="version: ${major_version}\\.[0-9]"
128+
local version_replace2="version: ${short_version}"
126129

127130
# Create a section in PR body for workflow file updates
128131
WORKFLOW_INSTRUCTIONS=""
129132
local any_needs_update=false
130133

131134
# Check each workflow file
132135
for workflow_file in $workflow_files; do
133-
if grep -q "$version_pattern" "$workflow_file"; then
136+
# Check for version: X.x pattern
137+
if grep -q "$version_pattern1" "$workflow_file"; then
134138
any_needs_update=true
135-
echo "Found workflow file needing update: $workflow_file"
139+
echo "Found workflow file needing update (pattern 1): $workflow_file"
136140

137141
# Get the line number and context for the PR description
138-
local line_info=$(grep -n "$version_pattern" "$workflow_file")
142+
local line_info=$(grep -n "$version_pattern1" "$workflow_file")
139143
local line_num=$(echo "$line_info" | cut -d':' -f1)
140144
local line_content=$(echo "$line_info" | cut -d':' -f2-)
141145

142146
# Add to workflow update instructions
143147
WORKFLOW_INSTRUCTIONS="${WORKFLOW_INSTRUCTIONS}
144148
- **$workflow_file** (line $line_num):
145149
- From: \`$line_content\`
146-
- To: \`$(echo "$line_content" | sed "s/$version_pattern/$version_replace/")\`"
150+
- To: \`$(echo "$line_content" | sed "s/$version_pattern1/$version_replace1/")\`"
151+
# Check for version: X.Y pattern
152+
elif grep -q "$version_pattern2" "$workflow_file"; then
153+
# Only consider it an update if the minor version actually changed
154+
local current_pattern="version: ${major_version}\\.${minor_version_old}"
155+
if grep -q "$current_pattern" "$workflow_file"; then
156+
any_needs_update=true
157+
echo "Found workflow file needing update (pattern 2): $workflow_file"
158+
159+
# Get the line number and context for the PR description
160+
local line_info=$(grep -n "$current_pattern" "$workflow_file")
161+
local line_num=$(echo "$line_info" | cut -d':' -f1)
162+
local line_content=$(echo "$line_info" | cut -d':' -f2-)
163+
164+
# Add to workflow update instructions
165+
WORKFLOW_INSTRUCTIONS="${WORKFLOW_INSTRUCTIONS}
166+
- **$workflow_file** (line $line_num):
167+
- From: \`$line_content\`
168+
- To: \`$(echo "$line_content" | sed "s/$current_pattern/version: ${short_version}/")\`"
169+
else
170+
echo "::info::Version pattern found but no update needed (current version): $workflow_file"
171+
fi
147172
else
148173
echo "::info::No matching pattern found, no update needed: $workflow_file"
149174
fi

.github/workflows/check-new-release.yml

+27-27
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ jobs:
5050
echo "::error::Required Dockerfiles not found!"
5151
exit 1
5252
fi
53-
53+
5454
CURRENT_INNOVATION=$(grep -oP '(?<=^ARG MYSQL_SHELL_VERSION=)\d+\.\d+\.\d+' docker/innovation/Dockerfile)
5555
CURRENT_LTS=$(grep -oP '(?<=^ARG MYSQL_SHELL_VERSION=)\d+\.\d+\.\d+' docker/lts/Dockerfile)
56-
56+
5757
if [[ -z "$CURRENT_INNOVATION" ]] || [[ -z "$CURRENT_LTS" ]]; then
5858
echo "::error::Failed to extract current versions from Dockerfiles"
5959
exit 1
6060
fi
61-
61+
6262
echo "CURRENT_INNOVATION=${CURRENT_INNOVATION}" >> $GITHUB_OUTPUT
6363
echo "CURRENT_LTS=${CURRENT_LTS}" >> $GITHUB_OUTPUT
6464
echo "Current Innovation: $CURRENT_INNOVATION"
6565
echo "Current LTS: $CURRENT_LTS"
66-
66+
6767
# Extract major versions (for later use)
6868
INNOVATION_MAJOR_VERSION=$(echo "$CURRENT_INNOVATION" | cut -d. -f1)
6969
LTS_MAJOR_VERSION=$(echo "$CURRENT_LTS" | cut -d. -f1)
@@ -76,7 +76,7 @@ jobs:
7676
# Get tag information from GitHub API
7777
INNOVATION_MAJOR="${{ steps.current_versions.outputs.INNOVATION_MAJOR_VERSION }}"
7878
LTS_MAJOR="${{ steps.current_versions.outputs.LTS_MAJOR_VERSION }}"
79-
79+
8080
# Use manually specified version for testing if provided
8181
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.innovation_version }}" ]]; then
8282
LATEST_INNOVATION="${{ github.event.inputs.innovation_version }}"
@@ -87,15 +87,15 @@ jobs:
8787
-H "X-GitHub-Api-Version: 2022-11-28" \
8888
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
8989
"https://api.github.com/repos/mysql/mysql-shell/tags?per_page=100")
90-
90+
9191
if [[ -z "$API_RESPONSE" ]] || [[ "$API_RESPONSE" == *"rate limit"* ]] || [[ "$API_RESPONSE" == *"Bad credentials"* ]]; then
9292
echo "::error::Failed to fetch data from GitHub API: $(echo "$API_RESPONSE" | grep -o '"message":"[^"]*"' || echo 'Unknown error')"
9393
exit 1
9494
fi
95-
95+
9696
# Dynamically build regex pattern
9797
INNOVATION_PATTERN="^${INNOVATION_MAJOR}\\.\\d+\\.\\d+$"
98-
98+
9999
LATEST_INNOVATION=$(echo "$API_RESPONSE" | jq -r --arg pattern "$INNOVATION_PATTERN" '[.[] | select(.name | test($pattern))][0].name')
100100
fi
101101
@@ -108,15 +108,15 @@ jobs:
108108
LTS_PATTERN="^${LTS_MAJOR}\\.\\d+\\.\\d+$"
109109
LATEST_LTS=$(echo "$API_RESPONSE" | jq -r --arg pattern "$LTS_PATTERN" '[.[] | select(.name | test($pattern))][0].name')
110110
fi
111-
111+
112112
# Validate results
113113
if [[ -z "$LATEST_INNOVATION" ]] || [[ "$LATEST_INNOVATION" == "null" ]] || [[ -z "$LATEST_LTS" ]] || [[ "$LATEST_LTS" == "null" ]]; then
114114
echo "::warning::Failed to find matching versions. Using hardcoded patterns as fallback."
115115
# Fallback: hardcoded version patterns
116116
LATEST_INNOVATION=${LATEST_INNOVATION:-$(echo "$API_RESPONSE" | jq -r '[.[] | select(.name | test("^9\\.\\d+\\.\\d+$"))][0].name')}
117117
LATEST_LTS=${LATEST_LTS:-$(echo "$API_RESPONSE" | jq -r '[.[] | select(.name | test("^8\\.\\d+\\.\\d+$"))][0].name')}
118118
fi
119-
119+
120120
echo "LATEST_INNOVATION=${LATEST_INNOVATION}" >> $GITHUB_OUTPUT
121121
echo "LATEST_LTS=${LATEST_LTS}" >> $GITHUB_OUTPUT
122122
echo "Latest Innovation: $LATEST_INNOVATION"
@@ -130,15 +130,15 @@ jobs:
130130
# Returns 0 if $1 > $2
131131
test "$(echo "$1 $2" | tr " " "\n" | sort -V | head -n 1)" != "$1"
132132
}
133-
133+
134134
CURRENT_INNOVATION="${{ steps.current_versions.outputs.CURRENT_INNOVATION }}"
135135
LATEST_INNOVATION="${{ steps.latest_tags.outputs.LATEST_INNOVATION }}"
136136
CURRENT_LTS="${{ steps.current_versions.outputs.CURRENT_LTS }}"
137137
LATEST_LTS="${{ steps.latest_tags.outputs.LATEST_LTS }}"
138-
138+
139139
INNOVATION_UPDATE_NEEDED="false"
140140
LTS_UPDATE_NEEDED="false"
141-
141+
142142
# Check Innovation version
143143
if [[ -z "$LATEST_INNOVATION" ]] || [[ "$LATEST_INNOVATION" == "null" ]]; then
144144
echo "::warning::No valid Innovation version found in API response"
@@ -152,7 +152,7 @@ jobs:
152152
else
153153
echo "Innovation is up-to-date at version $CURRENT_INNOVATION."
154154
fi
155-
155+
156156
# Check LTS version
157157
if [[ -z "$LATEST_LTS" ]] || [[ "$LATEST_LTS" == "null" ]]; then
158158
echo "::warning::No valid LTS version found in API response"
@@ -166,7 +166,7 @@ jobs:
166166
else
167167
echo "LTS is up-to-date at version $CURRENT_LTS."
168168
fi
169-
169+
170170
# In test mode, always report updates are needed
171171
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.dry_run }}" == "true" ]]; then
172172
if [[ -n "${{ github.event.inputs.innovation_version }}" ]]; then
@@ -178,7 +178,7 @@ jobs:
178178
LTS_UPDATE_NEEDED="true"
179179
fi
180180
fi
181-
181+
182182
echo "INNOVATION_UPDATE_NEEDED=${INNOVATION_UPDATE_NEEDED}" >> $GITHUB_OUTPUT
183183
echo "LTS_UPDATE_NEEDED=${LTS_UPDATE_NEEDED}" >> $GITHUB_OUTPUT
184184
@@ -210,19 +210,19 @@ jobs:
210210
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
211211
fi
212212
echo "Using branch name: $BRANCH_NAME"
213-
213+
214214
# Export as environment variable for scripts that need it
215215
export BRANCH_NAME
216-
216+
217217
# Set as output for reuse in subsequent steps
218218
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
219-
219+
220220
# Verify that update script exists before execution
221221
if [ ! -f .github/check-new-release/scripts/update.sh ]; then
222222
echo "::error::Script .github/check-new-release/scripts/update.sh not found"
223223
exit 1
224224
fi
225-
225+
226226
# Check if the script has execution permissions and capture exit status immediately
227227
if [ -x .github/check-new-release/scripts/update.sh ]; then
228228
# If executable, run directly
@@ -238,7 +238,7 @@ jobs:
238238
# Immediately capture exit status to avoid overwrites
239239
UPDATE_STATUS=$?
240240
fi
241-
241+
242242
# Check exit status
243243
if [ $UPDATE_STATUS -ne 0 ]; then
244244
echo "::error::Script update.sh exited with status $UPDATE_STATUS"
@@ -260,7 +260,7 @@ jobs:
260260
if [ -z "$BRANCH_NAME" ]; then
261261
echo "::warning::Branch name not available from previous step"
262262
echo "Generating fallback branch name based on version information"
263-
263+
264264
# Generate branch name using version information even in fallback
265265
if [[ "$INNOVATION_UPDATE_NEEDED" == "true" && "$LTS_UPDATE_NEEDED" == "true" ]]; then
266266
# Both versions need updating
@@ -275,21 +275,21 @@ jobs:
275275
# Ultimate fallback with timestamp
276276
BRANCH_NAME="bot/update-mysql-shell-fallback-$(date +%Y%m%d%H%M%S)"
277277
fi
278-
278+
279279
echo "Generated fallback branch name: $BRANCH_NAME"
280280
else
281281
echo "Using branch name from previous step: $BRANCH_NAME"
282282
fi
283-
283+
284284
# Export as environment variable for scripts that need it
285285
export BRANCH_NAME
286-
286+
287287
# Verify that post-message script exists before execution
288288
if [ ! -f .github/check-new-release/scripts/post-message.sh ]; then
289289
echo "::error::Script post-message.sh not found"
290290
exit 1
291291
fi
292-
292+
293293
# Check if the script has execution permissions and capture exit status immediately
294294
if [ -x .github/check-new-release/scripts/post-message.sh ]; then
295295
# If executable, run directly
@@ -305,7 +305,7 @@ jobs:
305305
# Immediately capture exit status to avoid overwrites
306306
POST_MESSAGE_STATUS=$?
307307
fi
308-
308+
309309
# Check exit status
310310
if [ $POST_MESSAGE_STATUS -ne 0 ]; then
311311
echo "::error::Script post-message.sh exited with status $POST_MESSAGE_STATUS"

.github/workflows/create-release-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ jobs:
4545
GIT_PR_RELEASE_BRANCH_STAGING: develop
4646
GIT_PR_RELEASE_TEMPLATE: .github/pr-release/template.erb
4747
GIT_PR_RELEASE_LABELS: release
48-
run: git-pr-release
48+
run: git-pr-release

.github/workflows/docker-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ jobs:
5555
tags: |
5656
snickerjp/docker-mysql-shell:${{ matrix.version }}
5757
snickerjp/docker-mysql-shell:${{ matrix.extra_tag }}
58-
${{ matrix.series == 'lts' && 'snickerjp/docker-mysql-shell:latest' || '' }}
58+
${{ matrix.series == 'lts' && 'snickerjp/docker-mysql-shell:latest' || '' }}

.github/workflows/docker-image.yml

-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ jobs:
5757
push: true
5858
tags: ${{ steps.meta.outputs.tags }}
5959
labels: ${{ steps.meta.outputs.labels }}
60-

.github/workflows/review-feature.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ jobs:
4040
script: |
4141
const prNumber = context.payload.pull_request.number;
4242
const branchName = context.payload.pull_request.head.ref;
43-
43+
4444
if (!branchName.startsWith('feat-')) {
4545
await github.rest.issues.createComment({
4646
owner: context.repo.owner,
4747
repo: context.repo.repo,
4848
issue_number: prNumber,
4949
body: '⚠️ Warning: Branch name should start with `feat-`'
5050
});
51-
}
51+
}

0 commit comments

Comments
 (0)