Skip to content

custom build and test: wAe0lYVi #348

custom build and test: wAe0lYVi

custom build and test: wAe0lYVi #348

# This workflow is a part of release automation process.
# It is intended to be run with workflow_dispatch event by the automation.
# In addition to regular tag builds, it also supports publishing unstable builds.
# Warning: Workflow does switch branches and this may lead to confusion when changing workflow actions.
# The usual safety rule is to make changes to workflow or actions in base branch (e.g, release/8.X)
# Version branches (e.g, 8.0.10-rc5-int8) will merge changes from base branch automatically.
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to build'
required: true
release_type:
description: 'Release type: either public or internal'
required: true
run_type:
description: 'Run type, either release, unstable or custom'
required: true
default: "custom"
workflow_uuid:
description: 'Optional UUID to identify this workflow run'
required: false
redisearch_version:
description: 'Redisearch version to build'
required: false
redisjson_version:
description: 'Redisjson version to build'
required: false
redisbloom_version:
description: 'Redisbloom version to build'
required: false
redistimeseries_version:
description: 'Redistimeseries version to build'
required: false
slack_channel_id:
description: 'Slack channel ID to post notifications to'
required: false
type: string
default: ''
slack_thread_ts:
description: 'Thread timestamp to post message as a reply (optional)'
required: false
type: string
default: ''
slack_fanout_msg_links:
description: 'Post message links to the announcement channel'
required: false
type: boolean
default: false
override_release_branch:
description: 'Use this release branch instead of release/X.X (for testing)'
required: false
type: string
# UUID is used to help automation to identify workflow run in the list of workflow runs.
run-name: "${{ github.event.inputs.run_type }} build and test${{ github.event.inputs.workflow_uuid && format(': {0}', github.event.inputs.workflow_uuid) || '' }}"
jobs:
prepare-release:
runs-on: ["ubuntu-latest"]
outputs:
slack_channel_id: ${{ steps.slack-routing.outputs.slack_channel_id }}
slack_thread_ts: ${{ steps.slack-routing.outputs.slack_thread_ts }}
slack_fanout_msg_links: ${{ steps.slack-routing.outputs.slack_fanout_msg_links }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install release automation dependencies
uses: ./.github/actions/release-automation-install
- name: Validate inputs
env:
INPUTS_RELEASE_TAG: ${{ github.event.inputs.release_tag }}
INPUTS_RELEASE_TYPE: ${{ github.event.inputs.release_type }}
INPUTS_RUN_TYPE: ${{ github.event.inputs.run_type }}
shell: bash
run: |
if ! [[ "$INPUTS_RELEASE_TYPE" =~ ^(public|internal)$ ]]; then
echo "::error::Invalid release type: $INPUTS_RELEASE_TYPE"
exit 1
fi
if ! [[ "$INPUTS_RUN_TYPE" =~ ^(release|unstable|custom)$ ]]; then
echo "::error::Invalid run type: $INPUTS_RUN_TYPE"
exit 1
fi
if [ "$INPUTS_RUN_TYPE" != "release" ] && [ "$INPUTS_RELEASE_TYPE" = "public" ]; then
echo "::error::Public release may have only run type 'release'"
exit 1
fi
# regular version means version is in X.X.X[-sss] format, not unstable and not custom
redis_version_is_regular=""
if uv --directory release-automation run release-automation redis-version major "$INPUTS_RELEASE_TAG"; then
redis_version_is_regular=1
fi
if [ "$INPUTS_RUN_TYPE" == "release" ] && [ -z "$redis_version_is_regular" ]; then
echo "::error::Release must be a regular version in X.Y.Z[-suffix] format"
exit 1
fi
- name: Setup slack message routing
id: slack-routing
env:
INPUTS_SLACK_CHANNEL_ID: ${{ github.event.inputs.slack_channel_id }}
INPUTS_SLACK_THREAD_TS: ${{ github.event.inputs.slack_thread_ts }}
INPUTS_RELEASE_TYPE: ${{ github.event.inputs.release_type }}
VARS_SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}
run: |
if [ "$INPUTS_RELEASE_TYPE" == "public" ]; then
# For public releases always post notifications to announcement channel
echo "slack_channel_id=$VARS_SLACK_CHANNEL_ID" | tee -a $GITHUB_OUTPUT
# Duplicate slack message links to the requested thread (if any)
echo "slack_fanout_msg_links=1" | tee -a $GITHUB_OUTPUT
else
echo "slack_channel_id=$INPUTS_SLACK_CHANNEL_ID" | tee -a $GITHUB_OUTPUT
fi
if [ -n "$INPUTS_SLACK_THREAD_TS" ]; then
echo "slack_thread_ts=$INPUTS_SLACK_THREAD_TS" | tee -a $GITHUB_OUTPUT
fi
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Redis Release Archive
if: github.event.inputs.run_type == 'release'
uses: redis-developer/redis-oss-release-automation/.github/actions/validate-redis-release-archive@main
with:
release_tag: ${{ github.event.inputs.release_tag }}
- name: Ensure Release Branch
id: ensure-branch
if: github.event.inputs.run_type == 'release'
uses: redis-developer/redis-oss-release-automation/.github/actions/ensure-release-branch@main
with:
release_tag: ${{ github.event.inputs.release_tag }}
allow_modify: true
gh_token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ github.event.inputs.override_release_branch }}
- name: Validate Dockerfiles are synced with templates
uses: ./.github/actions/validate-dockerfiles-synced
- name: Apply Docker Version
if: github.event.inputs.run_type == 'release'
id: apply-version
uses: ./.github/actions/apply-docker-version
with:
release_tag: ${{ github.event.inputs.release_tag }}
release_version_branch: ${{ steps.ensure-branch.outputs.release_version_branch }}
build-and-test:
uses: ./.github/workflows/build-n-test.yml
needs: prepare-release
secrets: inherit
with:
release_tag: ${{ github.event.inputs.release_tag }}
publish_image: true
redisearch_version: ${{ github.event.inputs.redisearch_version }}
redisjson_version: ${{ github.event.inputs.redisjson_version }}
redisbloom_version: ${{ github.event.inputs.redisbloom_version }}
redistimeseries_version: ${{ github.event.inputs.redistimeseries_version }}
run_type: ${{ github.event.inputs.run_type }}
slack_channel_id: ${{ needs.prepare-release.outputs.slack_channel_id }}
slack_thread_ts: ${{ needs.prepare-release.outputs.slack_thread_ts }}
override_release_branch: ${{ github.event.inputs.override_release_branch }}
finalize_release:
needs: [prepare-release, build-and-test]
runs-on: ["ubuntu-latest"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Ensure Release Branch
if: github.event.inputs.run_type == 'release'
id: ensure-branch
uses: redis-developer/redis-oss-release-automation/.github/actions/ensure-release-branch@main
with:
release_tag: ${{ github.event.inputs.release_tag }}
allow_modify: false
gh_token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ github.event.inputs.override_release_branch }}
- name: Merge back to release branch
if: github.event.inputs.release_type == 'public'
id: merge-back
uses: redis-developer/redis-oss-release-automation/.github/actions/merge-branches-verified@main
with:
from_branch: ${{ steps.ensure-branch.outputs.release_version_branch }}
to_branch: ${{ steps.ensure-branch.outputs.release_branch }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release handle JSON
id: create-release-handle
shell: bash
env:
NEEDS_DOCKER_IMAGES_METADATA: ${{ needs.build-and-test.outputs.docker_images_metadata }}
STEPS_MERGE_COMMIT_SHA: ${{ steps.merge-back.outputs.merge_commit_sha }}
STEPS_TARGET_BEFORE_MERGE_SHA: ${{ steps.merge-back.outputs.target_before_merge_sha }}
INPUTS_RELEASE_TAG: ${{ github.event.inputs.release_tag }}
STEPS_RELEASE_VERSION_BRANCH: ${{ steps.ensure-branch.outputs.release_version_branch }}
STEPS_RELEASE_BRANCH: ${{ steps.ensure-branch.outputs.release_branch }}
NEEDS_SLACK_TS: ${{ needs.build-and-test.outputs.slack_ts }}
INPUTS_SLACK_CHANNEL_ID: ${{ github.event.inputs.slack_channel_id }}
VARS_SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}
NEEDS_SLACK_URL: ${{ needs.build-and-test.outputs.slack_url }}
run: |
# Get docker images metadata from build-and-test job (required field)
DOCKER_IMAGES_METADATA="$NEEDS_DOCKER_IMAGES_METADATA"
# Validate that DOCKER_IMAGES_METADATA is valid JSON
if ! echo "$DOCKER_IMAGES_METADATA" | jq . > /dev/null 2>&1; then
echo "Warning: docker_images_metadata is not valid JSON, using empty array"
DOCKER_IMAGES_METADATA="[]"
fi
# Determine release_commit_sha
RELEASE_COMMIT_SHA="$STEPS_MERGE_COMMIT_SHA"
if [ -z "$RELEASE_COMMIT_SHA" ]; then
RELEASE_COMMIT_SHA="$STEPS_TARGET_BEFORE_MERGE_SHA"
fi
# Determine slack_channel_id
SLACK_CHANNEL_ID="${INPUTS_SLACK_CHANNEL_ID:-$VARS_SLACK_CHANNEL_ID}"
# Create JSON with all fields, then filter out empty ones
jq -n \
--argjson docker_images_metadata "$DOCKER_IMAGES_METADATA" \
--arg release_commit_sha "$RELEASE_COMMIT_SHA" \
--arg release_version "$INPUTS_RELEASE_TAG" \
--arg release_version_branch "$STEPS_RELEASE_VERSION_BRANCH" \
--arg release_branch "$STEPS_RELEASE_BRANCH" \
--arg slack_ts "$NEEDS_SLACK_TS" \
--arg slack_channel_id "$SLACK_CHANNEL_ID" \
--arg slack_message_url "$NEEDS_SLACK_URL" \
'{
docker_images_metadata: $docker_images_metadata,
release_commit_sha: $release_commit_sha,
release_version: $release_version,
release_version_branch: $release_version_branch,
release_branch: $release_branch,
slack_ts: $slack_ts,
slack_channel_id: $slack_channel_id,
slack_message_url: $slack_message_url
} | with_entries(select(.value != ""))' > result.json
echo "Created result.json for release_handle:"
cat result.json | jq '.'
- name: Upload release handle artifact
uses: actions/upload-artifact@v4
with:
name: release_handle
path: result.json
retention-days: 400
notify-slack-thread:
if: |
always() &&
needs.build-and-test.outputs.slack_url != '' &&
needs.prepare-release.outputs.slack_fanout_msg_links == '1' &&
github.event.inputs.slack_channel_id != ''
needs: [prepare-release, build-and-test]
runs-on: ["ubuntu-latest"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Post announcement link to Slack
uses: ./.github/actions/slack-notification
with:
slack_func: slack_format_simple_msg
slack_channel_id: ${{ github.event.inputs.slack_channel_id }}
release_tag: ${{ github.event.inputs.release_tag }}
slack_thread_ts: ${{ github.event.inputs.slack_thread_ts }}
message: ${{ needs.build-and-test.outputs.slack_url }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}