|
20 | 20 | parser.add_argument("--branch", default="main", help="Quartz branch to use for the artifact")
|
21 | 21 | parser.add_argument("--fpga", help="Name of FPGA project to release")
|
22 | 22 | parser.add_argument("--hubris", default=None, help="Path to hubris git checkout as target for copying files. Will skip if None")
|
| 23 | +parser.add_argument("--local", default=False, action="store_true", help="Path to local build directory. Will skip if None") |
23 | 24 | parser.add_argument("--skip-gh", default=False, action="store_true", help="Skip doing GH release. Note that doing this still generates release metadata that just will be wrong")
|
24 | 25 | parser.add_argument("--zip", default=None, help="Path to zip file to use instead of downloading from GitHub")
|
25 | 26 |
|
@@ -49,6 +50,15 @@ def main():
|
49 | 50 | print(f"Processing {args.fpga} with builder {project_info.builder}")
|
50 | 51 |
|
51 | 52 | # Get build archive
|
| 53 | + if args.local: |
| 54 | + print("Using local build directory") |
| 55 | + # make a zip file from the local build directory |
| 56 | + zip_file = make_buck2_zip() |
| 57 | + args.zip = str(zip_file) |
| 58 | + |
| 59 | + if args.zip: |
| 60 | + project_info.local = True |
| 61 | + |
52 | 62 | zip_file = process_gh_build(args, api, project_info.job_name)
|
53 | 63 | project_info.add_archive(zip_file)
|
54 | 64 |
|
@@ -99,11 +109,25 @@ def get_latest_artifact_info(api, fpga_name: str, branch: str = "main") -> dict:
|
99 | 109 | artifacts = sorted(artifacts, key=lambda x: arrow.get(x["created_at"]), reverse=True)
|
100 | 110 | return artifacts[0]
|
101 | 111 |
|
| 112 | + |
102 | 113 | def download_artifact(api: GhApi, artifact_inf: dict):
|
103 | 114 | print(f"Downloading artifact {artifact_inf['name']} from GH: {artifact_inf['workflow_run']['head_branch']}")
|
104 | 115 | r = requests.get(artifact_inf["archive_download_url"], auth=("oxidecomputer", os.getenv("GITHUB_TOKEN", None)))
|
105 | 116 | return zipfile.ZipFile(io.BytesIO(r.content))
|
106 | 117 |
|
| 118 | + |
| 119 | +def make_buck2_zip(): |
| 120 | + """ |
| 121 | + Create a zip file from the buck2 build directory. |
| 122 | + """ |
| 123 | + import shutil |
| 124 | + # Create object of ZipFile |
| 125 | + zipfile_path = Path.cwd() / Path("buck_out.zip") |
| 126 | + folder = Path.cwd() / "buck-out" / "v2" / "gen" / "root" |
| 127 | + shutil.make_archive(zipfile_path.with_suffix(''), 'zip', folder) |
| 128 | + return zipfile_path |
| 129 | + |
| 130 | + |
107 | 131 | if __name__ == '__main__':
|
108 | 132 | main()
|
109 | 133 |
|
|
0 commit comments