-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
122 additions
and
49 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Submodule schemas
updated
6 files
+27 −0 | .github/dependabot.yml | |
+4 −3 | .github/workflows/ci-build.yml | |
+54 −0 | .github/workflows/ci-verify.yml | |
+5 −0 | .github/workflows/verify-list | |
+3 −0 | HubConfig.fbs | |
+4 −4 | OpenShock.Serialization.Flatbuffers.csproj |
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,73 @@ | ||
import os | ||
import requests | ||
import zipfile | ||
import tempfile | ||
from pathlib import Path | ||
|
||
|
||
def fetch_latest_flatbuffers_release(output_dir): | ||
# API URL for the latest release | ||
api_url = "https://api.github.com/repos/google/flatbuffers/releases/latest" | ||
|
||
try: | ||
# Fetch the latest release data | ||
response = requests.get(api_url) | ||
response.raise_for_status() | ||
release_data = response.json() | ||
|
||
# Extract assets matching the desired filenames | ||
assets = release_data.get("assets", []) | ||
linux_asset = next((asset for asset in assets if "Linux.flatc.binary.clang" in asset["name"]), None) | ||
windows_asset = next((asset for asset in assets if "Windows.flatc.binary" in asset["name"]), None) | ||
|
||
if not linux_asset or not windows_asset: | ||
raise ValueError("Required assets not found in the latest release.") | ||
|
||
# Create a temporary directory for downloads | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
temp_dir_path = Path(temp_dir) | ||
|
||
# Download and extract Linux asset | ||
linux_zip_path = temp_dir_path / linux_asset["name"] | ||
download_file(linux_asset["browser_download_url"], linux_zip_path) | ||
extract_zip(linux_zip_path, output_dir) | ||
|
||
# Download and extract Windows asset | ||
windows_zip_path = temp_dir_path / windows_asset["name"] | ||
download_file(windows_asset["browser_download_url"], windows_zip_path) | ||
extract_zip(windows_zip_path, output_dir) | ||
|
||
print(f"Files have been successfully downloaded, extracted to {output_dir}, and temporary files deleted.") | ||
|
||
except requests.RequestException as e: | ||
print(f"Error fetching release data: {e}") | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
|
||
|
||
def download_file(url, dest_path): | ||
"""Download a file from a URL to the specified destination.""" | ||
response = requests.get(url, stream=True) | ||
response.raise_for_status() | ||
|
||
with open(dest_path, "wb") as f: | ||
for chunk in response.iter_content(chunk_size=8192): | ||
f.write(chunk) | ||
print(f"Downloaded: {dest_path}") | ||
|
||
|
||
def extract_zip(zip_path, extract_to): | ||
"""Extract a ZIP file to the specified directory.""" | ||
with zipfile.ZipFile(zip_path, "r") as zip_ref: | ||
zip_ref.extractall(extract_to) | ||
print(f"Extracted: {zip_path} to {extract_to}") | ||
|
||
|
||
if __name__ == "__main__": | ||
# Specify the output directory for the extracted files | ||
output_directory = Path(input("Enter the directory to extract the files to: ")).resolve() | ||
|
||
if not output_directory.exists(): | ||
output_directory.mkdir(parents=True) | ||
|
||
fetch_latest_flatbuffers_release(output_directory) |
Binary file not shown.
Binary file not shown.