-
Notifications
You must be signed in to change notification settings - Fork 30
[CLOUDP-361632] Add functionality to upload release info to GitHub release assets #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,12 @@ tasks: | |
| - func: install_macos_notarization_service | ||
| - func: release_kubectl_mongodb_plugin | ||
|
|
||
| - name: add_releaseinfo_to_github_assets | ||
| commands: | ||
| - func: clone | ||
| - func: python_venv | ||
| - func: add_releaseinfo_to_github_assets | ||
|
|
||
| - name: create_chart_release_pr | ||
| tags: [ "helm_chart_release_pr" ] | ||
| commands: | ||
|
|
@@ -151,6 +157,18 @@ buildvariants: | |
| - name: release_readiness_probe | ||
| - name: release_version_upgrade_hook | ||
|
|
||
| - name: add_releaseinfo_to_github_assets | ||
| display_name: add_releaseinfo_to_github_assets | ||
| tags: ["release"] | ||
| run_on: | ||
| - ubuntu2404-small | ||
| allowed_requesters: ["patch", "github_tag"] | ||
| # depends_on: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be uncommented, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
| # - name: "*" | ||
| # variant: release_images | ||
| tasks: | ||
| - name: add_releaseinfo_to_github_assets | ||
|
|
||
| - name: preflight_release_images | ||
| display_name: preflight_release_images | ||
| tags: [ "release" ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import argparse | ||
| import json | ||
| import pathlib | ||
| import os | ||
|
|
||
| from scripts.release.build.build_info import ( | ||
| DATABASE_IMAGE, | ||
|
|
@@ -10,81 +10,114 @@ | |
| OPERATOR_IMAGE, | ||
| READINESS_PROBE_IMAGE, | ||
| UPGRADE_HOOK_IMAGE, | ||
| OPS_MANAGER_IMAGE, | ||
| AGENT_IMAGE, | ||
| BuildInfo, | ||
| load_build_info, | ||
| ) | ||
| from scripts.release.kubectl_mongodb.promote_kubectl_plugin import upload_assets_to_github_release | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
| from scripts.release.build.build_scenario import BuildScenario | ||
| from scripts.release.constants import ( | ||
| DEFAULT_CHANGELOG_PATH, | ||
| DEFAULT_RELEASE_INITIAL_VERSION, | ||
| DEFAULT_REPOSITORY_PATH, | ||
| ) | ||
|
|
||
| SEARCH_IMAGE = "search" | ||
| SEARCH_IMAGE_REPOSITORY = "quay.io/mongodb/mongodb-search" | ||
|
|
||
| RELEASE_INFO_IMAGES_ORDERED = [ | ||
| OPERATOR_IMAGE, | ||
| INIT_DATABASE_IMAGE, | ||
| INIT_APPDB_IMAGE, | ||
| INIT_OPS_MANAGER_IMAGE, | ||
| DATABASE_IMAGE, | ||
| READINESS_PROBE_IMAGE, | ||
| UPGRADE_HOOK_IMAGE, | ||
| OPERATOR_IMAGE, # mongodb-kubernetes | ||
| INIT_DATABASE_IMAGE, # mongodb-kubernetes-init-database | ||
| INIT_APPDB_IMAGE, # mongodb-kubernetes-init-appdb | ||
| INIT_OPS_MANAGER_IMAGE, # mongodb-kubernetes-init-ops-manager | ||
| DATABASE_IMAGE, # mongodb-kubernetes-database | ||
| READINESS_PROBE_IMAGE, # mongodb-kubernetes-readinessprobe | ||
| UPGRADE_HOOK_IMAGE, # mongodb-kubernetes-operator-version-upgrade-post-start-hook | ||
| ] | ||
|
|
||
| # TODO: this is dummy version, to be replaced with actual versioning logic https://docs.google.com/document/d/1eJ8iKsI0libbpcJakGjxcPfbrTn8lmcZDbQH1UqMR_g/edit?tab=t.45ig7xr3e3w4#bookmark=id.748ik8snxcyl | ||
| DUMMY_VERSION = "dummy_version" | ||
|
|
||
| EXTERNAL_INFO_IMAGES = [ | ||
| OPS_MANAGER_IMAGE, | ||
| AGENT_IMAGE | ||
| ] | ||
|
|
||
| def create_release_info_json() -> str: | ||
| def create_release_info_json(version: str) -> str: | ||
| build_info = load_build_info(scenario=BuildScenario.RELEASE) | ||
|
|
||
| release_info_json = convert_to_release_info_json(build_info) | ||
| release_info_json = convert_to_release_info_json(build_info, version) | ||
|
|
||
| return json.dumps(release_info_json, indent=2) | ||
|
|
||
|
|
||
| def convert_to_release_info_json(build_info: BuildInfo) -> dict: | ||
| output = { | ||
| def convert_to_release_info_json(build_info: BuildInfo, version: str) -> dict: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. b: nit: |
||
| release_json_data = os.path.join(os.getcwd(), "release.json") | ||
| with open(release_json_data, "r") as fd: | ||
| release_data = json.load(fd) | ||
|
|
||
| release_info_output = { | ||
| "images": {}, | ||
| "binaries": {}, | ||
| "helm-charts": {}, | ||
| } | ||
| # Filter (and order) images to include only those relevant for release info | ||
| images = {name: build_info.images[name] for name in RELEASE_INFO_IMAGES_ORDERED} | ||
| images = {name: build_info.images[name] for name in RELEASE_INFO_IMAGES_ORDERED + EXTERNAL_INFO_IMAGES} | ||
|
|
||
| for name, image in images.items(): | ||
| output["images"][name] = { | ||
| release_info_output["images"][name] = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be simpler to just iterate over and then go manually with OPS_MANAGER_IMAGE and AGENT_IMAGE: # add operator related images
images = {name: build_info.images[name] for name in RELEASE_INFO_IMAGES_ORDERED
for name, image in images.items():
add_image(name, image.repositories, image.platforms, version)
# add Ops Manager image
om_image = build_info.images[OPS_MANAGER_IMAGE]
om_version = latest_om_version(release_data)
add_image(OPS_MANAGER_IMAGE, om_image.repositories, om_image.platforms, om_version)
# add Agent image
agent_image = build_info.images[AGENT_IMAGE]
agent_version = latest_agent_version(release_data)
add_image(AGENT_IMAGE, agent_image.repositories, agent_image.platforms, agent_version) |
||
| "repositories": image.repositories, | ||
| "platforms": image.platforms, | ||
| "version": DUMMY_VERSION, | ||
| } | ||
|
|
||
| if name == OPS_MANAGER_IMAGE: | ||
| release_info_output["images"][name]["version"] = latest_om_version(release_data) | ||
| continue | ||
|
|
||
| for name, binary in build_info.binaries.items(): | ||
| output["binaries"][name] = { | ||
| "platforms": binary.platforms, | ||
| "version": DUMMY_VERSION, | ||
| } | ||
| if name == AGENT_IMAGE: | ||
| release_info_output["images"][name]["version"] = latest_agent_version(release_data) | ||
| continue | ||
|
|
||
| for name, chart in build_info.helm_charts.items(): | ||
| output["helm-charts"][name] = { | ||
| "registry": chart.registry, | ||
| "repository": chart.repository, | ||
| "version": DUMMY_VERSION, | ||
| } | ||
| release_info_output["images"][name]["version"] = version | ||
|
|
||
| # add search image detail | ||
| release_info_output["images"][SEARCH_IMAGE] = { | ||
| "repositories": SEARCH_IMAGE_REPOSITORY, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather move this information to "supportedImages": {
"mongodb-search": {
"repository": "quay.io/mongodb/mongodb-search",
"platforms": [
"linux/arm64",
"linux/amd64"
],
"version": "0.55.0"
}
} |
||
| "platforms": ["linux/arm64", "linux/amd64"], | ||
| "version": latest_search_version(release_data) | ||
| } | ||
|
|
||
| release_info_output = add_om_agent_mappings(release_data, release_info_output) | ||
|
|
||
| return release_info_output | ||
|
|
||
| def add_om_agent_mappings(release_data, output): | ||
| om_agent_mapping = release_data["supportedImages"]["latestOpsManagerAgentMapping"] | ||
| output["latestOpsManagerAgentMapping"] = om_agent_mapping | ||
|
|
||
| return output | ||
|
|
||
| def latest_om_version(release_data): | ||
| return release_data["supportedImages"]["ops-manager"]["versions"][-1] | ||
|
|
||
| def latest_agent_version(release_data): | ||
| newest_om_version = release_data["supportedImages"]["ops-manager"]["versions"][-1] | ||
| newest_om_mapping = release_data["supportedImages"]["mongodb-agent"]["opsManagerMapping"]["ops_manager"][newest_om_version] | ||
| return newest_om_mapping["agent_version"] | ||
|
|
||
| def latest_search_version(release_data): | ||
| return release_data["search"]["version"] | ||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser( | ||
| description="Create relevant release artifacts information in JSON format.", | ||
| formatter_class=argparse.RawTextHelpFormatter, | ||
| ) | ||
| parser.add_argument("--version", help="released MCK version", required=True) | ||
| args = parser.parse_args() | ||
|
|
||
| release_info = create_release_info_json() | ||
| release_info_filename = f"release_info_{args.version}.json" | ||
|
|
||
| if args.output is not None: | ||
| with open(args.output, "w") as file: | ||
| release_info = create_release_info_json(args.version) | ||
|
|
||
| if release_info_filename is not None: | ||
| with open(release_info_filename, "w") as file: | ||
| file.write(release_info) | ||
| else: | ||
| print(release_info) | ||
|
|
||
| upload_assets_to_github_release([release_info_filename], args.version) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we add this to the image release? Right now its only manually run, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes to both? So you will make a change in this PR to make it run automatically, right?