Skip to content

Commit f00bde0

Browse files
authored
Merge pull request #43 from redis/unstable_update
Release automation update (for unstable)
2 parents f8fd60a + 8b82def commit f00bde0

File tree

16 files changed

+1211
-229
lines changed

16 files changed

+1211
-229
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Build binary package"
2+
inputs:
3+
run_id:
4+
description: "Run ID to download artifacts from"
5+
required: true
6+
dist:
7+
description: "Distribution to build for"
8+
required: true
9+
arch:
10+
description: "Architecture to build for"
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Determine build architecture
18+
shell: bash
19+
run: |
20+
case ${{ inputs.arch }} in
21+
i386)
22+
BUILD_ARCH=i386
23+
;;
24+
arm64)
25+
BUILD_ARCH=arm64
26+
;;
27+
armhf)
28+
BUILD_ARCH=armhf
29+
;;
30+
*)
31+
BUILD_ARCH=amd64
32+
;;
33+
esac
34+
35+
echo "BUILD_ARCH=${BUILD_ARCH}" >> $GITHUB_ENV
36+
- name: Install dependencies
37+
shell: bash
38+
run: |
39+
sudo apt-get update && \
40+
sudo apt-get install -y \
41+
sbuild debhelper \
42+
wget make cmake clang-format lcov git openssl libssl-dev unzip rsync pkg-config
43+
sudo sbuild-adduser $USER
44+
- name: Prepare sbuild environment
45+
shell: bash
46+
run: sudo ./setup_sbuild.sh ${{ inputs.dist }} ${{ env.BUILD_ARCH }}
47+
- name: Get source package
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: source-${{ inputs.dist }}
51+
run-id: ${{ inputs.run_id }}
52+
- name: Build binary package
53+
shell: bash
54+
run: |
55+
sudo sbuild \
56+
--nolog \
57+
--no-run-lintian \
58+
--host ${{ inputs.arch }} \
59+
--build ${{ env.BUILD_ARCH }} \
60+
--dist ${{ inputs.dist }} \
61+
--build-dep-resolver=apt \
62+
--chroot-setup-commands="apt-get update && apt-get install -y build-essential" \
63+
*.dsc
64+
- name: Upload binary package artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: binary-${{ inputs.dist }}-${{ inputs.arch }}
68+
path: |
69+
*.deb
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: "Build source package"
2+
3+
inputs:
4+
dist:
5+
description: "Distribution to build for"
6+
required: true
7+
release_tag:
8+
description: "Release tag to build for (value 'unstable' is supported)"
9+
required: false
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Install dependencies
16+
shell: bash
17+
run: |
18+
sudo apt-get update && \
19+
sudo apt-get install \
20+
debhelper dput tcl-tls libsystemd-dev pkgconf cmake clang libssl-dev
21+
- name: Determine version
22+
id: determine-version
23+
shell: bash
24+
run: |
25+
if [ "${{ inputs.release_tag }}" == "unstable" ]; then
26+
VERSION="unstable"
27+
URL="https://github.com/redis/redis/archive/refs/heads/${VERSION}.tar.gz"
28+
else
29+
# Version format:
30+
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
31+
VERSION=$(head -1 debian/changelog | awk '{print $2}' | sed 's/(\([0-9]\+:\)\?\(.*\)-[^-]\+)$/\2/g')
32+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
33+
URL="https://github.com/redis/redis/archive/${VERSION}.tar.gz"
34+
fi
35+
echo "Determined version $VERSION"
36+
echo "URL=${URL}"
37+
echo "URL=${URL}" >> $GITHUB_OUTPUT
38+
- name: Get source tarball
39+
shell: bash
40+
run: |
41+
curl --silent -L ${{ steps.determine-version.outputs.URL }} -o redis_${VERSION}.orig.tar.gz
42+
- name: Build source package
43+
shell: bash
44+
run: |
45+
mkdir -p redis-${VERSION}
46+
tar --extract --gunzip --file redis_${VERSION}.orig.tar.gz --strip-components=1 -C redis-${VERSION}
47+
sed -i 's/INSTALL_BIN=\$(PREFIX)\/bin/INSTALL_BIN=\$(DESTDIR)\$(PREFIX)\/bin/' redis-${VERSION}/src/Makefile
48+
49+
if [ "${{ inputs.release_tag }}" == "unstable" ]; then
50+
echo "===== Updating all Redis module versions to 'master' ====="
51+
find redis-${VERSION}/modules -name "Makefile" -type f | while read -r makefile; do
52+
echo "Processing $makefile"
53+
echo " Before change:"
54+
grep "MODULE_VERSION" "$makefile" || echo " No MODULE_VERSION found"
55+
56+
# Update the MODULE_VERSION to 'master'
57+
sed -i 's/MODULE_VERSION = .*/MODULE_VERSION = master/g' "$makefile"
58+
59+
echo " After change:"
60+
grep "MODULE_VERSION" "$makefile" || echo " No MODULE_VERSION found after update"
61+
echo "-----------------------------------"
62+
done
63+
echo "===== Module version updates completed ====="
64+
fi
65+
66+
cp -pr debian redis-${VERSION}
67+
sed -i "s/@RELEASE@/${{ inputs.dist }}/g" redis-${VERSION}/debian/changelog
68+
( cd redis-${VERSION} && dpkg-buildpackage -S )
69+
- name: Upload source package artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: source-${{ inputs.dist }}
73+
path: |
74+
redis_*.tar.xz
75+
redis_*.dsc
76+
redis_*.orig.tar.gz
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
# release_type currently is not used, but we keep it for future use
9+
release_type:
10+
description: 'Type of release to upload (public, internal)'
11+
required: true
12+
13+
outputs:
14+
changed_files:
15+
description: 'List of files that were modified'
16+
value: ${{ steps.apply-version.outputs.changed_files }}
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Checkout common functions
22+
uses: actions/checkout@v4
23+
with:
24+
repository: redis-developer/redis-oss-release-automation
25+
ref: main
26+
path: redis-oss-release-automation
27+
28+
- name: Bump Debian Changelog
29+
id: bump-version
30+
shell: bash
31+
run: |
32+
${{ github.action_path }}/bump-debian-changelog.sh ${{ inputs.release_tag }}
33+
34+
- name: Create verified commit
35+
if: steps.bump-version.outputs.changed_files != ''
36+
uses: iarekylew00t/verified-bot-commit@v1
37+
with:
38+
message: ${{ inputs.release_tag }}
39+
files: ${{ steps.bump-version.outputs.changed_files }}
40+
ref: ${{ inputs.release_version_branch }}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This script updates debian/changelog using the provided TAG
5+
# and 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+
echo "TAG: $TAG"
33+
34+
# Function to update changelog
35+
update_debian_changelog() {
36+
local changelog="$1"
37+
local tag="$2"
38+
39+
if [ ! -f "$changelog" ]; then
40+
echo "Warning: $changelog not found, skipping"
41+
return 1
42+
fi
43+
44+
echo "Updating $changelog..."
45+
46+
# Check if this version already exists in changelog
47+
if grep -q "^redis (.*:$tag-" "$changelog"; then
48+
echo "Version $tag already exists in $changelog, skipping"
49+
return 1
50+
fi
51+
52+
# Get author from the most recent entry
53+
AUTHOR=$(grep -m 1 '^ --' "$changelog" | sed 's/^ -- \(.*>\) *.*$/\1/')
54+
55+
if [ -z "$AUTHOR" ]; then
56+
echo "Error: Could not determine author from $changelog"
57+
return 1
58+
fi
59+
60+
# Create temporary file with new entry
61+
temp_changelog=$(mktemp)
62+
63+
# Add new entry at the top
64+
cat > "$temp_changelog" << EOF
65+
redis (6:$tag-1rl1~@RELEASE@1) @RELEASE@; urgency=low
66+
67+
* Redis $tag: https://github.com/redis/redis/releases/tag/$tag
68+
69+
-- $AUTHOR $(date -R)
70+
71+
EOF
72+
73+
# Append existing changelog
74+
cat "$changelog" >> "$temp_changelog"
75+
76+
# Replace original with updated version
77+
mv "$temp_changelog" "$changelog"
78+
79+
echo "Successfully updated $changelog with version $tag"
80+
return 0
81+
}
82+
83+
changelog_file="debian/changelog"
84+
# Track which files were modified
85+
changed_files=()
86+
87+
# Update the changelog
88+
if update_debian_changelog "$changelog_file" "$TAG"; then
89+
changed_files+=("$changelog_file")
90+
fi
91+
92+
# Check what files actually changed in git
93+
mapfile -t changed_files < <(git diff --name-only "$changelog_file")
94+
95+
# Output the list of changed files for GitHub Actions
96+
if [ ${#changed_files[@]} -gt 0 ]; then
97+
echo "Files were modified:"
98+
printf '%s\n' "${changed_files[@]}"
99+
100+
if [ -z "$GITHUB_OUTPUT" ]; then
101+
GITHUB_OUTPUT=/dev/stdout
102+
fi
103+
104+
# Set GitHub Actions output
105+
changed_files_output=$(printf '%s\n' "${changed_files[@]}")
106+
{
107+
echo "changed_files<<EOF"
108+
echo "$changed_files_output"
109+
echo "EOF"
110+
} >> "$GITHUB_OUTPUT"
111+
112+
echo "Changed files output set for next step"
113+
else
114+
echo "No files were modified"
115+
echo "changed_files=" >> "$GITHUB_OUTPUT"
116+
fi

.github/actions/common/func.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Sources a helper file from multiple possible locations (GITHUB_WORKSPACE, RELEASE_AUTOMATION_DIR, or relative path)
4+
source_helper_file() {
5+
local helper_file="$1"
6+
local helper_errors=""
7+
for dir in "GITHUB_WORKSPACE:$GITHUB_WORKSPACE/redis-oss-release-automation" "RELEASE_AUTOMATION_DIR:$RELEASE_AUTOMATION_DIR" ":../redis-oss-release-automation"; do
8+
local var_name="${dir%%:*}"
9+
local dir="${dir#*:}"
10+
if [ -n "$var_name" ]; then
11+
var_name="\$$var_name"
12+
fi
13+
local helper_path="$dir/.github/actions/common/$helper_file"
14+
if [ -f "$helper_path" ]; then
15+
helper_errors=""
16+
# shellcheck disable=SC1090
17+
. "$helper_path"
18+
break
19+
else
20+
helper_errors=$(printf "%s\n %s: %s" "$helper_errors" "$var_name" "$helper_path")
21+
fi
22+
done
23+
if [ -n "$helper_errors" ]; then
24+
echo "Error: $helper_file not found in any of the following locations: $helper_errors" >&2
25+
exit 1
26+
fi
27+
}

0 commit comments

Comments
 (0)