Skip to content

Commit 8583db5

Browse files
committed
buildroot/rebuild.py: Add support for uploading images to a GitHub release
Rather than storing the rootfs files in the repository directly, we can upload them to a GitHub release, which does not impact the repository size when closing. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent eb62d39 commit 8583db5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

buildroot/rebuild.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
from argparse import ArgumentParser
4+
import datetime
45
import os
56
from pathlib import Path
67
import shutil
@@ -22,6 +23,8 @@
2223
'x86',
2324
'x86_64',
2425
]
26+
RELEASE_TAG = datetime.datetime.now(
27+
tz=datetime.timezone.utc).strftime('%Y%m%d-%H%M%S')
2528
ROOT_FOLDER = Path(__file__).resolve().parent
2629
OUT_FOLDER = Path(ROOT_FOLDER, 'out')
2730
SRC_FOLDER = Path(ROOT_FOLDER, 'src')
@@ -111,6 +114,19 @@ def download_buildroot_if_necessary():
111114
download_and_extract_buildroot()
112115

113116

117+
def release_images():
118+
if not shutil.which('gh'):
119+
raise RuntimeError(
120+
"Could not find GitHub CLI ('gh') on your system, please install it to do releases!"
121+
)
122+
123+
gh_cmd = [
124+
'gh', '-R', 'ClangBuiltLinux/boot-utils', 'release', 'create',
125+
'--generate-notes', RELEASE_TAG, *list(OUT_FOLDER.iterdir())
126+
]
127+
subprocess.run(gh_cmd, check=True)
128+
129+
114130
def parse_arguments():
115131
parser = ArgumentParser()
116132

@@ -127,6 +143,11 @@ def parse_arguments():
127143
'--edit-config',
128144
action='store_true',
129145
help='Edit configuration file and run savedefconfig on result')
146+
parser.add_argument(
147+
'-r',
148+
'--release',
149+
action='store_true',
150+
help=f"Create a release on GitHub (tag: {RELEASE_TAG})")
130151

131152
return parser.parse_args()
132153

@@ -143,3 +164,6 @@ def parse_arguments():
143164
download_buildroot_if_necessary()
144165
for arch in architectures:
145166
build_image(arch, args.edit_config)
167+
168+
if args.release:
169+
release_images()

0 commit comments

Comments
 (0)