Skip to content

Commit fe29f68

Browse files
committed
Merge remote-tracking branch 'origin/release/8.4' into unstable-alignment
Add release automation to unstable branch
2 parents e5cdb81 + ec9d20f commit fe29f68

File tree

11 files changed

+1069
-100
lines changed

11 files changed

+1069
-100
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
inputs:
2+
release_tag:
3+
description: 'Release tag to build'
4+
required: true
5+
release_version_branch:
6+
description: 'Release version branch to commit to'
7+
required: true
8+
9+
outputs:
10+
changed_files:
11+
description: 'List of files that were modified'
12+
value: ${{ steps.apply-version.outputs.changed_files }}
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Checkout common functions
18+
uses: actions/checkout@v4
19+
with:
20+
repository: redis-developer/redis-oss-release-automation
21+
ref: main
22+
path: redis-oss-release-automation
23+
24+
- name: Apply docker version
25+
id: apply-version
26+
shell: bash
27+
run: |
28+
${{ github.action_path }}/apply-docker-version.sh ${{ inputs.release_tag }}
29+
30+
- name: Create verified commit
31+
if: steps.apply-version.outputs.changed_files != ''
32+
uses: iarekylew00t/verified-bot-commit@v1
33+
with:
34+
message: ${{ inputs.release_tag }}
35+
files: ${{ steps.apply-version.outputs.changed_files }}
36+
ref: ${{ inputs.release_version_branch }}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This script updates Redis version in Dockerfiles using environment variables
5+
# REDIS_ARCHIVE_URL and REDIS_ARCHIVE_SHA, then commits changes if any were made.
6+
7+
# shellcheck disable=SC2034
8+
last_cmd_stdout=""
9+
# shellcheck disable=SC2034
10+
last_cmd_stderr=""
11+
# shellcheck disable=SC2034
12+
last_cmd_result=0
13+
# shellcheck disable=SC2034
14+
VERBOSITY=1
15+
16+
17+
18+
SCRIPT_DIR="$(dirname -- "$( readlink -f -- "$0"; )")"
19+
# shellcheck disable=SC1091
20+
. "$SCRIPT_DIR/../common/func.sh"
21+
22+
source_helper_file helpers.sh
23+
24+
# Input TAG is expected in $1
25+
TAG="$1"
26+
27+
if [ -z "$TAG" ]; then
28+
echo "Error: TAG is required as first argument"
29+
exit 1
30+
fi
31+
32+
# Check if required environment variables are set
33+
if [ -z "$REDIS_ARCHIVE_URL" ]; then
34+
echo "Error: REDIS_ARCHIVE_URL environment variable is not set"
35+
exit 1
36+
fi
37+
38+
if [ -z "$REDIS_ARCHIVE_SHA" ]; then
39+
echo "Error: REDIS_ARCHIVE_SHA environment variable is not set"
40+
exit 1
41+
fi
42+
43+
echo "TAG: $TAG"
44+
echo "REDIS_ARCHIVE_URL: $REDIS_ARCHIVE_URL"
45+
echo "REDIS_ARCHIVE_SHA: $REDIS_ARCHIVE_SHA"
46+
47+
# Function to update Dockerfile
48+
update_dockerfile() {
49+
local dockerfile="$1"
50+
local updated=false
51+
52+
if [ ! -f "$dockerfile" ]; then
53+
echo "Warning: $dockerfile not found, skipping"
54+
return 1
55+
fi
56+
57+
echo "Updating $dockerfile..."
58+
59+
# Update REDIS_DOWNLOAD_URL
60+
if grep -q "^ENV REDIS_DOWNLOAD_URL=" "$dockerfile"; then
61+
sed -i "s|^ENV REDIS_DOWNLOAD_URL=.*|ENV REDIS_DOWNLOAD_URL=$REDIS_ARCHIVE_URL|" "$dockerfile"
62+
else
63+
echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_URL not found"
64+
return 1
65+
fi
66+
67+
68+
# Update REDIS_DOWNLOAD_SHA
69+
if grep -q "^ENV REDIS_DOWNLOAD_SHA=" "$dockerfile"; then
70+
sed -i "s|^ENV REDIS_DOWNLOAD_SHA=.*|ENV REDIS_DOWNLOAD_SHA=$REDIS_ARCHIVE_SHA|" "$dockerfile"
71+
else
72+
echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_SHA not found"
73+
return 1
74+
fi
75+
}
76+
77+
docker_files=("debian/Dockerfile" "alpine/Dockerfile")
78+
# Track which files were modified
79+
changed_files=()
80+
81+
for dockerfile in "${docker_files[@]}"; do
82+
update_dockerfile "$dockerfile"
83+
done
84+
85+
changed_files=($(git diff --name-only "${docker_files[@]}"))
86+
87+
# Output the list of changed files for GitHub Actions
88+
if [ ${#changed_files[@]} -gt 0 ]; then
89+
echo "Files were modified:"
90+
printf '%s\n' "${changed_files[@]}"
91+
92+
# Set GitHub Actions output
93+
changed_files_output=$(printf '%s\n' "${changed_files[@]}")
94+
{
95+
echo "changed_files<<EOF"
96+
echo "$changed_files_output"
97+
echo "EOF"
98+
} >> "$GITHUB_OUTPUT"
99+
100+
echo "Changed files output set for next step"
101+
else
102+
echo "No files were modified"
103+
echo "changed_files=" >> "$GITHUB_OUTPUT"
104+
fi

.github/actions/build-and-tag-locally/action.yml

Lines changed: 90 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Build and Test
2+
description: Build and test redis docker image
23

34
inputs:
45
distribution:
@@ -19,6 +20,21 @@ inputs:
1920
registry_repository:
2021
description: 'Repository to push the image to'
2122
required: false
23+
release_tag:
24+
description: 'Release tag to build'
25+
required: false
26+
redisearch_version:
27+
description: 'Redisearch version to build'
28+
required: false
29+
redisjson_version:
30+
description: 'Redisjson version to build'
31+
required: false
32+
redisbloom_version:
33+
description: 'Redisbloom version to build'
34+
required: false
35+
redistimeseries_version:
36+
description: 'Redistimeseries version to build'
37+
required: false
2238

2339
runs:
2440
using: "composite"
@@ -54,9 +70,6 @@ runs:
5470
linux/i386)
5571
plaform_name="i386"
5672
;;
57-
linux/mips64le)
58-
plaform_name="mips64le"
59-
;;
6073
linux/ppc64le)
6174
plaform_name="ppc64le"
6275
;;
@@ -88,88 +101,27 @@ runs:
88101
password: ${{ inputs.registry_password }}
89102

90103
- name: Build
91-
id: build
92104
uses: docker/build-push-action@v6
93105
with:
94106
context: ${{ inputs.distribution }}
95107
push: false
96108
load: true
97109
platforms: ${{ inputs.platform }}
98110
tags: ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
99-
cache-from: type=gha
100-
cache-to: type=gha,mode=max
101-
env:
102-
BUILDKIT_PROGRESS: plain
103-
104-
- name: Capture build logs on failure
105-
shell: bash
106-
if: failure() && steps.build.outcome == 'failure'
107-
run: |
108-
mkdir -p /tmp/build-logs
109-
110-
echo "Build failed for ${{ inputs.distribution }} on ${{ inputs.platform }}"
111-
echo "Capturing detailed logs for troubleshooting..."
112-
113-
# Get docker history for the built image (might not exist if build failed early)
114-
docker history ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-history.log 2>&1 || echo "Failed to get image history"
115-
116-
# Get docker inspect output (might not exist if build failed early)
117-
docker inspect ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-inspect.json 2>&1 || echo "Failed to inspect image"
118-
119-
# Get docker build cache info
120-
docker buildx du > /tmp/build-logs/buildx-du.log 2>&1 || echo "Failed to get build cache info"
121-
122-
# Get system info
123-
uname -a > /tmp/build-logs/system-info.log 2>&1
124-
docker info > /tmp/build-logs/docker-info.log 2>&1
125-
126-
# Create a summary file
127-
{
128-
echo "Build failure summary for ${{ inputs.distribution }} on ${{ inputs.platform }}"
129-
echo "Date: $(date)"
130-
echo "GitHub SHA: ${{ github.sha }}"
131-
echo "Platform: ${{ steps.platform.outputs.display_name }}"
132-
echo "Distribution: ${{ inputs.distribution }}"
133-
} > /tmp/build-logs/failure-summary.txt
134-
135-
# Try to extract error information from the build logs
136-
echo "Analyzing build failure..."
137-
138-
# Check for common error patterns
139-
if docker buildx build --no-cache ${{ inputs.distribution }} --platform=${{ inputs.platform }} 2>&1 | tee /tmp/build-logs/build-error.log | grep -q "ERROR"; then
140-
echo "Found ERROR in build output"
141-
grep -A 10 -B 5 "ERROR" /tmp/build-logs/build-error.log > /tmp/build-logs/error-context.log || true
142-
fi
143-
144-
echo "Log capture complete"
145-
146-
- name: Upload build failure logs
147-
if: failure() && steps.build.outcome == 'failure'
148-
uses: actions/upload-artifact@v4
149-
with:
150-
name: build-failure-${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}
151-
path: /tmp/build-logs/
152-
retention-days: 30
153-
if-no-files-found: warn
154-
155-
- name: Save image
156-
shell: bash
157-
run: |
158-
docker save -o /tmp/image-${{ steps.platform.outputs.display_name }}.tar ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
159-
160-
- name: Upload image
161-
uses: actions/upload-artifact@v4
162-
with:
163-
name: ${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}-docker-image.tar
164-
path: /tmp/image-${{ steps.platform.outputs.display_name }}.tar
165-
retention-days: 45
111+
cache-from: type=gha,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
112+
cache-to: type=gha,mode=max,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
113+
build-args: |
114+
REDISEARCH_VERSION=${{ inputs.redisearch_version }}
115+
REDISJSON_VERSION=${{ inputs.redisjson_version }}
116+
REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
117+
REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
166118
167119
- name: Run container
168120
shell: bash
169121
if: ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
170122
run: |
171123
docker run -d --name sanity-test-${{ steps.platform.outputs.display_name }} ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
172-
124+
173125
- name: Container Logs
174126
if: ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
175127
shell: bash
@@ -182,7 +134,7 @@ runs:
182134
run: |
183135
docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli ping
184136
docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli info server
185-
137+
186138
- name: Verify installed modules
187139
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
188140
shell: bash
@@ -202,7 +154,7 @@ runs:
202154
echo "The following modules are missing: ${missing_modules[*]}"
203155
exit 1
204156
fi
205-
157+
206158
- name: Test RedisBloom
207159
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
208160
shell: bash
@@ -212,7 +164,7 @@ runs:
212164
[ "$(docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli BF.EXISTS popular_keys "redis:hash")" = "1" ] || { echo "RedisBloom test failed: 'redis:hash' not found"; exit 1; }
213165
[ "$(docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli BF.EXISTS popular_keys "redis:list")" = "0" ] || { echo "RedisBloom test failed: 'redis:list' found unexpectedly"; exit 1; }
214166
echo "RedisBloom test passed successfully"
215-
167+
216168
- name: Test RediSearch
217169
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
218170
shell: bash
@@ -257,6 +209,7 @@ runs:
257209
echo "ReJSON test failed: expected 'allkeys-lru', got $result"
258210
exit 1
259211
fi
212+
260213
- name: Test the entrypoint
261214
id: test_entrypoint
262215
if: ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
@@ -277,12 +230,73 @@ runs:
277230
path: test/report-entrypoint.xml
278231
reporter: java-junit
279232

233+
- name: Format registry tag
234+
id: format-registry-tag
235+
shell: bash
236+
run: |
237+
printf "tag=%s:%s%s-%s-%s" \
238+
"${{ inputs.registry_repository }}" \
239+
"${{ inputs.release_tag != '' && format('{0}-', inputs.release_tag || '') }}" \
240+
"${{ github.run_id }}" \
241+
"${{ inputs.distribution }}" \
242+
"${{ steps.platform.outputs.display_name }}" \
243+
| tr '[:upper:]' '[:lower:]' >> "$GITHUB_OUTPUT"
244+
245+
- name: Image labels
246+
if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
247+
id: get-image-labels
248+
uses: ./.github/actions/create-image-labels
249+
with:
250+
redis_version: ${{ inputs.release_tag }}
251+
redisearch_version: ${{ inputs.redisearch_version }}
252+
redisjson_version: ${{ inputs.redisjson_version }}
253+
redisbloom_version: ${{ inputs.redisbloom_version }}
254+
redistimeseries_version: ${{ inputs.redistimeseries_version }}
255+
280256
- name: Push image
281257
uses: docker/build-push-action@v6
282258
if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
283259
with:
284260
context: ${{ inputs.distribution }}
285261
push: true
286-
tags: ${{ inputs.registry_repository }}:${{ github.sha }}-${{ inputs.distribution }}
262+
tags: ${{ steps.format-registry-tag.outputs.tag }}
287263
cache-from: type=gha
288264
cache-to: type=gha,mode=max
265+
build-args: |
266+
REDISEARCH_VERSION=${{ inputs.redisearch_version }}
267+
REDISJSON_VERSION=${{ inputs.redisjson_version }}
268+
REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
269+
REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
270+
labels: |
271+
${{ steps.get-image-labels.outputs.image_labels }}
272+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
273+
org.opencontainers.image.revision=${{ github.sha }}
274+
275+
- name: Save image metadata to artifact
276+
shell: bash
277+
run: |
278+
if [[ "${{ inputs.publish_image }}" == "true" && "${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}" == "true" ]]; then
279+
# Create a JSON file with structured image metadata
280+
mkdir -p /tmp/image-metadata
281+
cat > "/tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json" << 'EOF'
282+
{
283+
"version": "${{ inputs.release_tag }}",
284+
"arch": "${{ steps.platform.outputs.display_name }}",
285+
"distro": "${{ inputs.distribution }}",
286+
"commit": "${{ github.sha }}",
287+
"url": "${{ steps.format-registry-tag.outputs.tag }}"
288+
}
289+
EOF
290+
echo "Image metadata saved:"
291+
cat "/tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json"
292+
else
293+
echo "Image not published for this platform/distribution combination"
294+
fi
295+
296+
- name: Upload image metadata artifact
297+
uses: actions/upload-artifact@v4
298+
if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
299+
with:
300+
name: image-metadata-${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
301+
path: /tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json
302+
retention-days: 1

0 commit comments

Comments
 (0)