Release Build and Test: e5497743-9d34-46f2-b09a-1ded6096843a #25
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 images metadata from build-and-test job | |
| DOCKER_IMAGES_METADATA='${{ needs.build-and-test.outputs.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 | |
| cat > result.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_images_metadata": $DOCKER_IMAGES_METADATA | |
| } | |
| EOF | |
| echo "Created result.json for release_handle:" | |
| cat result.json | |
| - name: Upload release handle artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release_handle | |
| path: result.json | |
| retention-days: 400 |