Release Build and Test: 04fba8d6-0647-4b6b-b326-abb9ae2ac163 #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow is a part of release automation process. | |
# It is intended to be run with workflow_dispatch event by the automation. | |
# 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 | |
workflow_uuid: | |
description: 'Optional UUID to identify this workflow run' | |
required: false | |
# UUID is used to help automation to identify workflow run in the list of workflow runs. | |
run-name: "Release Build and Test${{ github.event.inputs.workflow_uuid && format(': {0}', github.event.inputs.workflow_uuid) || '' }}" | |
jobs: | |
prepare-release: | |
runs-on: ["ubuntu-latest"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- 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 | |
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 | |
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 }} | |
- name: Apply Docker Version | |
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/pre-merge.yml | |
needs: prepare-release | |
secrets: inherit | |
with: | |
release_tag: ${{ github.event.inputs.release_tag }} | |
publish_image: true | |
merge-back-to-release-branch: | |
needs: [prepare-release, build-and-test] | |
if: success() | |
runs-on: ["ubuntu-latest"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Ensure Release Branch | |
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 }} | |
- name: Merge back to release branch | |
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 | |
shell: bash | |
run: | | |
if [ -n "${{ steps.merge-back.outputs.merge_commit_sha }}" ]; then | |
RELEASE_COMMIT_SHA="${{ steps.merge-back.outputs.merge_commit_sha }}" | |
elif [ -n "${{ steps.merge-back.outputs.target_before_merge_sha }}" ]; then | |
RELEASE_COMMIT_SHA="${{ steps.merge-back.outputs.target_before_merge_sha }}" | |
else | |
echo "Error: No commit SHA found, both merge_commit_sha and target_before_merge_sha are empty" >&2 | |
exit 1 | |
fi | |
# Get docker image URLs from build-and-test job | |
DOCKER_IMAGE_URLS='${{ needs.build-and-test.outputs.docker_image_urls }}' | |
# Validate that DOCKER_IMAGE_URLS is valid JSON | |
if ! echo "$DOCKER_IMAGE_URLS" | jq . > /dev/null 2>&1; then | |
echo "Warning: docker_image_urls is not valid JSON, using empty array" | |
DOCKER_IMAGE_URLS="[]" | |
fi | |
cat > release_handle.json << EOF | |
{ | |
"release_commit_sha": "$RELEASE_COMMIT_SHA", | |
"release_version": "${{ github.event.inputs.release_tag }}", | |
"release_version_branch": "${{ steps.ensure-branch.outputs.release_version_branch }}", | |
"release_branch": "${{ steps.ensure-branch.outputs.release_branch }}", | |
"docker_image_urls": $DOCKER_IMAGE_URLS | |
} | |
EOF | |
echo "Created release_handle.json:" | |
cat release_handle.json | |
- name: Upload release handle artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release_handle | |
path: release_handle.json | |
retention-days: 400 |