Skip to content

Commit 88c4970

Browse files
authored
Merge pull request #474 from Peter-Sh/release/8.2
Release automation: release/8.2
2 parents a13b788 + 8a94c07 commit 88c4970

30 files changed

+3814
-28
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: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
registry_repository:
2020
description: 'Repository to push the image to'
2121
required: false
22+
release_tag:
23+
description: 'Release tag to build'
24+
required: false
2225

2326
runs:
2427
using: "composite"
@@ -95,14 +98,14 @@ runs:
9598
load: true
9699
platforms: ${{ inputs.platform }}
97100
tags: ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
98-
cache-from: type=gha
99-
cache-to: type=gha,mode=max
101+
cache-from: type=gha,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
102+
cache-to: type=gha,mode=max,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
100103

101104
- name: Save image
102105
shell: bash
103106
run: |
104107
docker save -o /tmp/image-${{ steps.platform.outputs.display_name }}.tar ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
105-
108+
106109
- name: Upload image
107110
uses: actions/upload-artifact@v4
108111
with:
@@ -115,7 +118,7 @@ runs:
115118
if: ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
116119
run: |
117120
docker run -d --name sanity-test-${{ steps.platform.outputs.display_name }} ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
118-
121+
119122
- name: Container Logs
120123
if: ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
121124
shell: bash
@@ -128,7 +131,7 @@ runs:
128131
run: |
129132
docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli ping
130133
docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli info server
131-
134+
132135
- name: Verify installed modules
133136
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
134137
shell: bash
@@ -148,7 +151,7 @@ runs:
148151
echo "The following modules are missing: ${missing_modules[*]}"
149152
exit 1
150153
fi
151-
154+
152155
- name: Test RedisBloom
153156
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
154157
shell: bash
@@ -158,7 +161,7 @@ runs:
158161
[ "$(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; }
159162
[ "$(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; }
160163
echo "RedisBloom test passed successfully"
161-
164+
162165
- name: Test RediSearch
163166
if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
164167
shell: bash
@@ -224,12 +227,44 @@ runs:
224227
path: test/report-entrypoint.xml
225228
reporter: java-junit
226229

230+
- name: Format registry tag
231+
id: format-registry-tag
232+
shell: bash
233+
run: |
234+
printf "tag=%s:%s%s-%s-%s" \
235+
"${{ inputs.registry_repository }}" \
236+
"${{ inputs.release_tag != '' && format('{0}-', inputs.release_tag || '') }}" \
237+
"${{ github.sha }}" \
238+
"${{ inputs.distribution }}" \
239+
"${{ steps.platform.outputs.display_name }}" \
240+
| tr '[:upper:]' '[:lower:]' >> "$GITHUB_OUTPUT"
241+
227242
- name: Push image
228243
uses: docker/build-push-action@v6
229244
if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
230245
with:
231246
context: ${{ inputs.distribution }}
232247
push: true
233-
tags: ${{ inputs.registry_repository }}:${{ github.sha }}-${{ inputs.distribution }}
248+
tags: ${{ steps.format-registry-tag.outputs.tag }}
234249
cache-from: type=gha
235250
cache-to: type=gha,mode=max
251+
252+
- name: Save image URL to artifact
253+
shell: bash
254+
run: |
255+
if [[ "${{ inputs.publish_image }}" == "true" && "${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}" == "true" ]]; then
256+
# Create a file with the image URL for this specific build
257+
mkdir -p /tmp/image-urls
258+
echo "${{ steps.format-registry-tag.outputs.tag }}" > "/tmp/image-urls/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.txt"
259+
echo "Image URL saved: ${{ steps.format-registry-tag.outputs.tag }}"
260+
else
261+
echo "Image not published for this platform/distribution combination"
262+
fi
263+
264+
- name: Upload image URL artifact
265+
uses: actions/upload-artifact@v4
266+
if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
267+
with:
268+
name: image-url-${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
269+
path: /tmp/image-urls/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.txt
270+
retention-days: 1

0 commit comments

Comments
 (0)