-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding release automation script (#242)
- Loading branch information
Showing
4 changed files
with
410 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"repository_sets": [ | ||
{ | ||
"image_repos": [ | ||
{ | ||
"name": "nephio", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false, | ||
"images": [ | ||
"nephio/nephio-operator:v2.0.0", | ||
"nephio/vlan-fn:v2.0.0", | ||
"nephio/nfdeploy-fn:v2.0.0", | ||
"nephio/nad-fn:v2.0.0", | ||
"nephio/ipam-fn:v2.0.0", | ||
"nephio/interface-fn:v2.0.0", | ||
"nephio/gen-configmap-fn:v2.0.0", | ||
"nephio/dnn-fn:v2.0.0", | ||
"nephio/configinject-fn:v2.0.0", | ||
"nephio/ueransim-deploy-fn:v2.0.0" | ||
] | ||
}, | ||
{ | ||
"name": "kpt-backstage-plugins", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false, | ||
"images": [ | ||
"nephio/kpt-backstage-plugins:v2.0.0" | ||
] | ||
}, | ||
{ | ||
"name": "free5gc", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false, | ||
"images": [ | ||
"nephio/free5gc-operator:v2.0.0" | ||
] | ||
}, | ||
{ | ||
"name": "oai", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false, | ||
"images": [ | ||
"nephio/oai-ran-controller:v2.0.0" | ||
] | ||
}, | ||
{ | ||
"name": "porch", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false, | ||
"images": [ | ||
"nephio/porch-server:v2.0.0", | ||
"nephio/porch-controllers", | ||
"nephio/porch-function-runner", | ||
"nephio/porch-wrapper-server" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_repos": [ | ||
{ | ||
"name": "catalog", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false | ||
}, | ||
{ | ||
"name": "api", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false | ||
}, | ||
{ | ||
"name": "test-infra", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false | ||
}, | ||
{ | ||
"name": "docs", | ||
"tag": "v2.0.0", | ||
"title": "R2", | ||
"body": "Release notes for version 2.0.0", | ||
"draft": false, | ||
"prerelease": false | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import util as u | ||
from contextlib import chdir | ||
|
||
try: | ||
import git | ||
except ImportError: | ||
print("GitPython is not installed.") | ||
exit(1) | ||
|
||
# Create releases in repositories with image build jobs with the new release tag: | ||
|
||
config_file_path = "config.json" | ||
repository_sets = u.read_config_file(config_file_path) | ||
|
||
def image_repos_create_release(org): | ||
for repo_set in repository_sets: | ||
image_repos = repo_set.get("image_repos", []) | ||
for repo in image_repos: | ||
repo_name = repo["name"] | ||
tag_name = repo["tag"] | ||
title = repo["title"] | ||
clone_url = f"https://github.com/{org}/{repo_name}.git" | ||
repo_path = f"{repo_name}_clone" | ||
images = repo["images"] | ||
git.Repo.clone_from(clone_url, repo_path) | ||
|
||
# Create a GitHub release | ||
with chdir(repo_path): | ||
u.set_default_repo(org,repo_name) | ||
u.create_github_release(repo_name, tag_name, title) | ||
# Wait for each image set to be built | ||
for image in images: | ||
u.wait_for_images(image) | ||
|
||
def tag_external_images(old_tag, new_tag): | ||
# Tag nephio/resource-backend-controller and nephio/network-config-operator | ||
for image_name in {"nephio/resource-backend-controller", "nephio/network-config-operator"}: | ||
u.tag_docker_images(image_name,old_tag, new_tag) | ||
# Fixme: push those tagged images automatically | ||
print("Push docker images manually to the hub") | ||
input("Press Enter to continue...") | ||
|
||
def package_repos_create_release(org, old_release, new_release, modify_versions=False): | ||
# Create releases in the package repositories with the release tag | ||
|
||
for repo_set in repository_sets: | ||
package_repos = repo_set.get("package_repos", []) | ||
for repo in package_repos: | ||
repo_name = repo["name"] | ||
tag_name = repo["tag"] | ||
title = repo["title"] | ||
body = repo["body"] | ||
base_branch = "main" | ||
head_branch = "release_temp_branch" # Replace with a branch name of your choice | ||
|
||
# Clone the repository | ||
clone_url = f"https://github.com/{org}/{repo_name}.git" | ||
repo_path = f"{repo_name}_clone" | ||
git.Repo.clone_from(clone_url, repo_path) | ||
if modify_versions: | ||
# Modify content in the cloned repository | ||
u.modify_repo_content(repo_path, old_release, new_release) | ||
|
||
# Commit changes and push to the repository | ||
repo = git.Repo(repo_path) | ||
repo.git.push("origin", head_branch) | ||
|
||
# Create a pull request for the changes | ||
pr_title = f"Update content in {head_branch} for the release" | ||
pr_body = f"This pull request bumps versions for the release" | ||
u.create_pull_request(repo_name, base_branch, head_branch, pr_title, pr_body) | ||
#XXX FIXME: check pr status and create release automatically after PR is merged | ||
# Create a GitHub release | ||
u.create_github_release(repo_name, tag_name, title, body) | ||
|
||
def release_catalog(org, tag_name, title): | ||
# Clone the repository | ||
clone_url = f"https://github.com/{org}/catalog.git" | ||
repo_path = f"catalog_clone" | ||
git.Repo.clone_from(clone_url, repo_path) | ||
|
||
# Create a GitHub release | ||
with chdir(repo_path): | ||
u.set_default_repo(org,"catalog") | ||
u.create_github_release("catalog", tag_name, title) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
if not u.is_gh_installed(): | ||
print("GitHub CLI (gh) is not installed.") | ||
print("Visit: https://cli.github.com/") | ||
exit(1) | ||
print("Checking authorization: \n") | ||
u.check_gh_auth() | ||
input("Press Enter to create release in image producing repositories") | ||
print("Creating releases in image producing repositories: \n") | ||
image_repos_create_release(org="nephio-project") | ||
input("Press Enter to release rest of the repositories") | ||
package_repos_create_release(org="nephio-project") | ||
#tag_external_images() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
docker==7.0.0 | ||
gitdb==4.0.11 | ||
GitPython==3.1.41 | ||
idna==3.6 | ||
packaging==23.2 | ||
requests==2.31.0 | ||
smmap==5.0.1 | ||
termcolor==2.4.0 | ||
urllib3==2.2.0 |
Oops, something went wrong.