Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/get-hazelcast-platform-pr-title/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To ensure that both setter and getter use the same format

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add move logging:

      run: |
        title="Hazelcast platform release ${{ inputs.hz-version }}"
        echo "title=$title" >> "$GITHUB_OUTPUT"
        echo "Generated PR title: $title"

and use step output as action output

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will already be able to see that output in the debug logs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but then I need to re-run or check consumer of this steps. I think it makes debugging easier when action print basic information by default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more logging - 8224a7f

You can see the output of that command in the regular logs already:

image

If the information is already there I would rather leave as is than duplicately log incase they diverge.

name: Get Hazelcast Platform PR Title

inputs:
hz-version:
required: true
outputs:
title:
value: Hazelcast platform release ${{ inputs.hz-version }}
runs:
using: "composite"
steps:
- shell: bash
run: exit 0
6 changes: 3 additions & 3 deletions .github/python/add-release/add_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def update_hazelcast_open_source_metadata(version_metadata: VersionMetadata):

version_block = f"""---
Version: {version_metadata.version}
Date: {version_metadata.date}
Date: ${{TBC_RELEASE_DATE}}
Download_ZIP_URL: {version_metadata.os_downloads.full_zip.url}
Download_ZIP_Size: {version_metadata.os_downloads.full_zip.size}
Download_slim_ZIP_URL: {version_metadata.os_downloads.slim_zip.url}
Expand Down Expand Up @@ -74,7 +74,7 @@ def update_hazelcast_enterprise_metadata(version_metadata: VersionMetadata):

version_block = f"""---
Version: {version_metadata.version}
Date: {version_metadata.date}
Date: ${{TBC_RELEASE_DATE}}
Download_ZIP_URL: {version_metadata.ee_downloads.full_zip.url}
Download_ZIP_Size: {version_metadata.ee_downloads.full_zip.size}
Download_slim_ZIP_URL: {version_metadata.ee_downloads.slim_zip.url}
Expand Down Expand Up @@ -153,7 +153,7 @@ def update_imdg_clients_metadata(version_metadata: VersionMetadata):

version_block = f"""---
Version: {version_metadata.version}
Date: {version_metadata.date}
Date: ${{TBC_RELEASE_DATE}}
Download: {version_metadata.os_downloads.slim_zip.url}
Download_Size: {version_metadata.os_downloads.slim_zip.size}
Github: {version_metadata.sources_url}
Expand Down
3 changes: 0 additions & 3 deletions .github/python/add-release/version_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
from dataclasses import InitVar, dataclass, field
from datetime import datetime

import requests
import semver
Expand Down Expand Up @@ -69,8 +68,6 @@ def __post_init__(self, github_org, ee_release_repo_name):
if isinstance(self.version, str):
self.version = semver.Version.parse(self.version)

self.date = datetime.now().strftime("%m/%d/%Y")

self.os_downloads = self._build_downloads(
f"https://github.com/{github_org}/hazelcast/releases/download/v{self.version}/hazelcast-{self.version}"
)
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Package Hazelcast platform release metadata
description: Creates a draft PR for the updated release metadata, after adding the required Hazelcast platform release
run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`@${{ inputs.ENVIRONMENT }})

on:
# Called from release pipeline
workflow_dispatch:
inputs:
VERSION:
description: 'The version to release (e.g. `5.4.1`)'
required: true
RELEASE_TYPE:
description: 'What should be built'
required: true
type: choice
options:
- ALL
- OSS
- EE
ENVIRONMENT:
description: 'Environment to use'
required: true
type: environment

jobs:
package:
environment:
name: ${{ inputs.ENVIRONMENT }}
deployment: false
runs-on: ubuntu-slim
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- uses: actions/checkout@v6
# Required to get the default branch as well, to allow `gh` to accurately determine the diff between branches when deriving PR title from commits
Comment thread
nishaatr marked this conversation as resolved.
with:
fetch-depth: 0

- id: resolve-editions
uses: hazelcast/docker-actions/resolve-editions@master
with:
release-type: ${{ inputs.RELEASE_TYPE }}

- uses: hazelcast/docker-actions/get-jfrog-credentials@master
# Other environments use public artifacts, where credentials aren't required
Comment thread
nishaatr marked this conversation as resolved.
if: inputs.ENVIRONMENT == 'sandbox'
id: jfrog
with:
aws-role-to-assume: ${{ vars.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }}
jfrog-oidc-provider-name: ${{ github.repository_owner }}-snapshot-internal

- name: Install dependencies
run: |
pip3 install -r .github/python/add-release/requirements.txt

- name: Update metadata
run: |
python3 .github/python/add-release/add_release.py \
--version=${VERSION} \
--github-org=${GITHUB_REPOSITORY_OWNER} \
--ee-release-repo-name=${{ vars.EE_RELEASE_REPO_NAME }} \
--should-build-oss=${{ steps.resolve-editions.outputs.should_build_oss }} \
--should-build-ee=${{ steps.resolve-editions.outputs.should_build_ee }}
env:
VERSION: ${{ inputs.VERSION }}
RELEASE_REPO_USER: ${{ steps.jfrog.outputs.user }}
RELEASE_REPO_TOKEN: ${{ steps.jfrog.outputs.token }}

- uses: ./.github/actions/get-hazelcast-platform-pr-title
id: get-pr-title
with:
hz-version: ${{ inputs.VERSION }}

- name: Create PR for changes
Comment thread
ldziedziul marked this conversation as resolved.
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

# Make a new branch from the default one
# The default branch is the ultimate target of the PR, not the current one
# For _typical_ workflow execution this is the same
# But when testing changes, if running from the non-default branch (e.g. a branch with your workflow changes), the resultant version update PR will _also_ include those changes
git checkout \
-b "${{ github.job }}_run_${{ github.run_id }}" \
Comment thread
nishaatr marked this conversation as resolved.
${{ github.event.repository.default_branch }}

git commit \
--all \
--message="${{ steps.get-pr-title.outputs.title }}" \
--message="Generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}."
git push -u origin HEAD

gh pr create \
--assignee "${GITHUB_ACTOR}" \
--fill \
--draft
env:
GH_TOKEN: ${{ github.token }}
104 changes: 67 additions & 37 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,110 @@
name: Add Hazelcast platform release
run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`@${{ inputs.ENVIRONMENT }})
name: Promote Hazelcast platform release metadata
description: Identifies the corresponding PR for the updated release metadata from `package.yml`, updating as required and merging
run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`)

on:
# Called from release orchestrator
workflow_dispatch:
inputs:
VERSION:
description: 'The version to release (e.g. `5.4.1`)'
description: 'The version to promote (e.g. `5.4.1`)'
required: true
RELEASE_TYPE:
description: 'What should be built'
required: true
description: 'Unused, provided for compatibility with a common release promotion interface'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the plan for these redundant inputs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have one - this is the first time it's come up. I don't think think it's terrible this way?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a task to backlog to not forget about it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task for what? Not sure what the solution would be, if any.

required: false
type: choice
options:
- ALL
- OSS
- EE
ENVIRONMENT:
description: 'Environment to use'
required: true
description: 'Unused, provided for compatibility with a common release promotion interface'
required: false
type: environment
distinct_id:
description: 'Required exclusively for automated execution to track status of workflow execution'
required: false

jobs:
add-release:
environment: ${{ inputs.ENVIRONMENT }}
promote:
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ inputs.VERSION }}
pull-requests: write
steps:
# https://github.com/Codex-/return-dispatch#receiving-repository-action
- name: Logging distinct ID (${{ inputs.distinct_id }})
run: echo "${DISTINCT_ID}"
env:
DISTINCT_ID: ${{ inputs.distinct_id }}

- uses: actions/checkout@v6
- name: Checkout repo
uses: actions/checkout@v6

- id: resolve-editions
uses: hazelcast/docker-actions/resolve-editions@master
- uses: ./.github/actions/get-hazelcast-platform-pr-title
id: get-pr-title
with:
release-type: ${{ inputs.RELEASE_TYPE }}
hz-version: ${{ inputs.VERSION }}

- name: Find corresponding staged PR
id: find-pr
run: |
set -o errexit -o nounset -o pipefail ${RUNNER_DEBUG:+-x}

source /dev/stdin <<< "$(curl --silent https://raw.githubusercontent.com/hazelcast/github-actions-common-scripts/main/logging.functions.sh)"

PR_JSON=$(gh pr list \
--search "'${{ steps.get-pr-title.outputs.title }}' in:title author:app/github-actions" \
--json number,headRefName \
--jq '.[0]')
Comment thread
nishaatr marked this conversation as resolved.

echodebug "PR search result - ${PR_JSON}"

PR_NUMBER=$(jq -r .number <<< "${PR_JSON}")
PR_BRANCH=$(jq -r .headRefName <<< "${PR_JSON}")

- uses: hazelcast/docker-actions/get-jfrog-credentials@master
if: inputs.ENVIRONMENT == 'sandbox'
id: jfrog
echo "Found PR = #${PR_NUMBER}, branch = ${PR_BRANCH}"

if [[ -n "${PR_NUMBER}" || -n "${PR_BRANCH}" ]]; then
echo "PR_NUMBER=${PR_NUMBER}" >> ${GITHUB_OUTPUT}
Comment thread
JackPGreen marked this conversation as resolved.
echo "PR_BRANCH=${PR_BRANCH}" >> ${GITHUB_OUTPUT}
else
echoerr "No matching PR found to promote"
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}

- name: 'Checkout PR #${{ steps.find-pr.outputs.PR_NUMBER }} (`${{ steps.find-pr.outputs.PR_BRANCH }}`)'
uses: actions/checkout@v6
with:
aws-role-to-assume: ${{ vars.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }}
jfrog-oidc-provider-name: ${{ github.repository_owner }}-snapshot-internal
ref: ${{ steps.find-pr.outputs.PR_BRANCH }}

- name: Install dependencies
- name: Update release date in files
run: |
pip3 install -r .github/python/add-release/requirements.txt
export TBC_RELEASE_DATE=$(date +%m/%d/%Y)
echo "Updating TBC_RELEASE_DATE -> ${TBC_RELEASE_DATE}..."

- name: Update metadata
run: |
python3 .github/python/add-release/add_release.py \
--version=${VERSION} \
--github-org=${GITHUB_REPOSITORY_OWNER} \
--ee-release-repo-name=${{ vars.EE_RELEASE_REPO_NAME }} \
--should-build-oss=${{ steps.resolve-editions.outputs.should_build_oss }} \
--should-build-ee=${{ steps.resolve-editions.outputs.should_build_ee }}
env:
RELEASE_REPO_USER: ${{ steps.jfrog.outputs.user }}
RELEASE_REPO_TOKEN: ${{ steps.jfrog.outputs.token }}
find . -type f -name "*.txt" -print0 | while IFS= read -r -d '' file; do
envsubst '$TBC_RELEASE_DATE' < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}"
Comment thread
JackPGreen marked this conversation as resolved.
done

- name: Push back changes
- name: 'Commit changes to PR #${{ steps.find-pr.outputs.PR_NUMBER }}'
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

git commit --all \
--message="Hazelcast platform release ${VERSION}" \

git commit \
--all \
--message="Updating release date" \
--message="Generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}."
git push

- name: 'Merge PR #${{ steps.find-pr.outputs.PR_NUMBER }}'
run: |
gh pr ready

gh pr merge \
--squash
Comment thread
nishaatr marked this conversation as resolved.
env:
GH_TOKEN: ${{ github.token }}
Loading